Условие where pdoPage
Подскажите как реализовать в pdoPage условие больше 100 и меньше 150 у поля area
{'!pdoPage' | snippet : [
'ajaxMode' => 'default',
'parents' => 23,
'tpl' => 'projectcard',
'limit' => 15,
'includeTVs' => 'number,size,area,img,number,price1',
'tvPrefix' => '',
'includeContent' => 1,
'where' => '{"area:=<": 150 AND "area:>": 100}',
'tplPageWrapper' => '@INLINE <div class="pagination"><ul class="pagination pagination-lg">{$prev}{$pages}{$next}</ul></div>',
'tplPage' => '@INLINE <li><a href="{$href}">{$pageNo}</a></li>',
'tplPageActive' => '@INLINE <li class="active"><a href="{$href}">{$pageNo}</a></li>',
'tplPagePrev' => '@INLINE <li rel="prev"><a href="{$href}">« Назад</a></li>',
'tplPageNext' => '@INLINE <li rel="next"><a href="{$href}">Дальше »</a></li>',
'tplPagePrevEmpty' => '@INLINE ',
'tplPageNextEmpty' => '@INLINE ',
'ajaxElemWrapper' => '#child_list',
'ajaxElemRows' => '#child_list .rows',
'ajaxElemPagination' => '#child_list .pagination',
'ajaxElemLink' => '#child_list .pagination a',
]}
Комментарии: 9
Пишите так:
'where' => ['area:=<' => 150]
это же всего одно условие
'where' => ['area:=<' => 150, 'area:>'=> 100 ]
не работает такой код, может из-за fenom синтаксис не такой?
'showLog' => 1
или 'return' => 'sql'
{'!pdoPage' | snippet : [
'ajaxMode' => 'default',
'parents' => 23,
'tpl' => 'projectcard',
'limit' => 15,
'includeTVs' => 'number,size,area,img,number,price1',
'tvPrefix' => '',
'includeContent' => 1,
'showLog' => 1
'where' => '{"area:<": 150}',
]}
Вот такой код например выводит с полем 120, но не выводит с полем 88 Это лог
0.0000288: pdoTools loaded
0.0000081: xPDO query object created
0.0002019: Included list of tvs: img, number, size, area, price1
0.0000541: leftJoined modTemplateVarResource as TVimg
0.0000379: leftJoined modTemplateVarResource as TVnumber
0.0000360: leftJoined modTemplateVarResource as TVsize
0.0000339: leftJoined modTemplateVarResource as TVarea
0.0000339: leftJoined modTemplateVarResource as TVprice1
0.0000541: Added selection of modResource: SQL_CALC_FOUND_ROWS `id`, `type`, `contentType`, `pagetitle`, `longtitle`, `description`, `alias`, `link_attributes`, `published`, `pub_date`, `unpub_date`, `parent`, `isfolder`, `introtext`, `content`, `richtext`, `template`, `menuindex`, `searchable`, `cacheable`, `createdby`, `createdon`, `editedby`, `editedon`, `deleted`, `deletedon`, `deletedby`, `publishedon`, `publishedby`, `menutitle`, `donthit`, `privateweb`, `privatemgr`, `content_dispo`, `hidemenu`, `class_key`, `context_key`, `content_type`, `uri`, `uri_override`, `hide_children_in_tree`, `show_in_tree`, `properties`
0.0000031: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `img`
0.0000019: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `number`
0.0000010: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `size`
0.0000010: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `area`
0.0000010: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `price1`
0.0000041: Replaced TV conditions
0.0001600: Processed additional conditions
0.0002320: Added where condition: `TVarea`.`value`:<=150, modResource.parent:IN(23,27,30,31,32,33), modResource.published=1, modResource.deleted=0
0.0000019: Replaced TV conditions
0.0000250: Sorted by modResource.publishedon, DESC
0.0000010: Limited to 15, offset 0
0.0000992: SQL prepared «SELECT SQL_CALC_FOUND_ROWS `modResource`.`id`, `modResource`.`type`, `modResource`.`contentType`, `modResource`.`pagetitle`, `modResource`.`longtitle`, `modResource`.`description`, `modResource`.`alias`, `modResource`.`link_attributes`, `modResource`.`published`, `modResource`.`pub_date`, `modResource`.`unpub_date`, `modResource`.`parent`, `modResource`.`isfolder`, `modResource`.`introtext`, `modResource`.`content`, `modResource`.`richtext`, `modResource`.`template`, `modResource`.`menuindex`, `modResource`.`searchable`, `modResource`.`cacheable`, `modResource`.`createdby`, `modResource`.`createdon`, `modResource`.`editedby`, `modResource`.`editedon`, `modResource`.`deleted`, `modResource`.`deletedon`, `modResource`.`deletedby`, `modResource`.`publishedon`, `modResource`.`publishedby`, `modResource`.`menutitle`, `modResource`.`donthit`, `modResource`.`privateweb`, `modResource`.`privatemgr`, `modResource`.`content_dispo`, `modResource`.`hidemenu`, `modResource`.`class_key`, `modResource`.`context_key`, `modResource`.`content_type`, `modResource`.`uri`, `modResource`.`uri_override`, `modResource`.`hide_children_in_tree`, `modResource`.`show_in_tree`, `modResource`.`properties`, IFNULL(`TVimg`.`value`, '') AS `img`, IFNULL(`TVnumber`.`value`, '') AS `number`, IFNULL(`TVsize`.`value`, '') AS `size`, IFNULL(`TVarea`.`value`, '') AS `area`, IFNULL(`TVprice1`.`value`, '') AS `price1` FROM `So3BJk6L7nih_site_content` AS `modResource` LEFT JOIN `So3BJk6L7nih_site_tmplvar_contentvalues` `TVimg` ON `TVimg`.`contentid` = `modResource`.`id` AND `TVimg`.`tmplvarid` = 1 LEFT JOIN `So3BJk6L7nih_site_tmplvar_contentvalues` `TVnumber` ON `TVnumber`.`contentid` = `modResource`.`id` AND `TVnumber`.`tmplvarid` = 9 LEFT JOIN `So3BJk6L7nih_site_tmplvar_contentvalues` `TVsize` ON `TVsize`.`contentid` = `modResource`.`id` AND `TVsize`.`tmplvarid` = 10 LEFT JOIN `So3BJk6L7nih_site_tmplvar_contentvalues` `TVarea` ON `TVarea`.`contentid` = `modResource`.`id` AND `TVarea`.`tmplvarid` = 11 LEFT JOIN `So3BJk6L7nih_site_tmplvar_contentvalues` `TVprice1` ON `TVprice1`.`contentid` = `modResource`.`id` AND `TVprice1`.`tmplvarid` = 30 WHERE ( `TVarea`.`value` < '150' AND `modResource`.`parent` IN (23,27,30,31,32,33) AND `modResource`.`published` = 1 AND `modResource`.`deleted` = 0 ) ORDER BY modResource.publishedon DESC LIMIT 15 „
0.0004909: SQL executed
0.0000470: Total rows: 1
0.0000091: Rows fetched
0.0017550: Prepared and processed TVs
0.0003450: Loaded “modChunk» with name «projectcard»
0.0049419: Compiled Fenom chunk with name «modchunk/31»
0.0004802: Loaded «modSnippet» with name «phpthumbon»
0.0006108: Loaded «modSnippet» with name «numformat»
0.0065000: Returning processed chunks
0.0097070: Total time
4 194 304: Memory usage
'where' => [['area:=<' => 150], ['area:>'=> 100] ]?
'where' => ['area:=<' => 150, 'AND:area:>'=> 100 ]?
'where' => ['area:=<' => 150, 'AND:area:>'=> 100 ]?
Квадратные скобки ошибку выдают
Could not process query, error #1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=< '150' AND `TVarea`.`value` > '100' AND `modResource`.`parent` IN (23,27,30,31' at line 1
Could not process query, error #1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=< '150' AND `TVarea`.`value` > '100' AND `modResource`.`parent` IN (23,27,30,31' at line 1
Решение нашёл здесь modx.pro/help/3374/#comment-26244
'where' => '["`TVarea`.`value` BETWEEN 100 and 150"]',
Есть другой вопрос, как сюда добавить еще условие например floor==1
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.