我如何表达where条款:
select * from TABLE where LENGTH(COLUMN) > 0在xPDO?
$criteria->where(array('LENGTH(customer_po_num):>' => '0'));如果不起作用,就会产生这样的结果:
`InventoryData`.`LENGTH(customer_po_num)` > '0' 发布于 2014-11-01 20:39:26
最后我就这样做了:
$criteria->where(
array('`InventoryData`.`id` NOT IN (SELECT id FROM modx_gssi_inventory_data where LENGTH(customer_po_num) > 0)'));不确定这是最好的方法,但它是有效的。
发布于 2014-11-03 03:37:17
对于不支持的SQL运算符,通常可以将条件作为字符串而不是数组包含到查询中:
$criteria->where('LENGTH(customer_po_num) > 0');编辑:下面提供的工作示例
$c = $modx->newQuery('modResource');
$c->where('LENGTH(pagetitle) > 0');
$c->select('pagetitle');
$c->prepare();
print_r($c->toSql());返回以下(工作) SQL:
SELECT `pagetitle`
FROM `ovo_site_content`
AS `modResource`
WHERE LENGTH(pagetitle) > 0它起作用了。
https://stackoverflow.com/questions/26692290
复制相似问题