modxmodx-revolutionmodx-resourcesxpdo

xPDO compiles integer as string


$query = $this->modx->newQuery('modResource');
$query->leftJoin('modTemplateVarResource', "price", array("modResource.id = price.contentid", "price.tmplvarid = 2"));
$query->where(array("price:>=" => 6000));
$query->prepare();
echo $query->toSql();

RETURNS:

`modResource`.`context_key` AS `modResource_context_key`, `modResource`.`content_type` AS `modResource_content_type`, `modResource`.`uri` AS `modResource_uri`, `modResource`.`uri_override` AS `modResource_uri_override`, `modResource`.`hide_children_in_tree` AS `modResource_hide_children_in_tree`, `modResource`.`show_in_tree` AS `modResource_show_in_tree`, `modResource`.`properties` AS `modResource_properties`
FROM `modx_site_content` AS `modResource`
LEFT JOIN `modx_site_tmplvar_contentvalues` `price` 
    ON ( modResource.id = price.contentid 
        AND price.tmplvarid = 2 ) 
WHERE `modResource`.`price` >= '6000' 

Why is integer quoted? It should be treated as an int.


Solution

  • It seems i found another solution - the easiest way is

    $query->where("price.value >= 6000");

    and best way to combine with okyanet solution

    $query->where("CAST(price.value AS UNSIGNED INTEGER) >= 6000");

    All of them works correct in xPDO