ModX xPDO字符串加在where子句中的整数中

时间:2019-04-19 01:59:56

标签: php modx xpdo

xPDO字符串加在where子句中

型号:

<object class="glCity" table="gl_cities" extends="xPDOSimpleObject">
....    
<field key="name_ru" dbtype="varchar" precision="128" phptype="varchar" null="false" default=""/>
    <field key="name_en" dbtype="varchar" precision="128" phptype="varchar" null="false" default=""/>
....
</object>

方法:

public function prepareQueryBeforeCount(xPDOQuery $c)
{
    ......
    if ($query) {
        $c->where(array(
            "{$this->objectType}.name_ru:LIKE"    => "%{$query}%",
            "OR:{$this->objectType}.name_en:LIKE" => "%{$query}%",
        ));
    }
    $c->where(array(
            "{$this->objectType}.name_ru:LIKE"    => "11",
            "OR:{$this->objectType}.name_en:LIKE" => (string)"bbbb",
        ));
    $c->prepare();
    echo '<pre>';print_r($c->toSQL());echo '</pre>';exit;
    return $c;
}

返回

 SELECT * FROM `modx_gl_cities` AS `glCity` LEFT JOIN `modx_gl_data` `glData` ON glData.identifier = glCity.id WHERE  ( `glCity`.`active` = 1 AND `glCity`.`default` = 0 AND  ( `glCity`.`name_ru` LIKE 0 OR `glCity`.`name_en` LIKE 0 )  AND  ( `glCity`.`name_ru` LIKE 11 OR `glCity`.`name_en` LIKE 0 )  ) 

我不知道该怎么做,以至于会有一个数字代替一个数字。

0 个答案:

没有答案