mysqlmodxmodx-revolutionxpdo

How to convert SQL where LENGTH() condition to xPDO?


How do I express the where clause in this:

select * from TABLE where LENGTH(COLUMN)  > 0

in xPDO?

$criteria->where(array('LENGTH(customer_po_num):>' => '0'));

does not work, it results in something like this:

`InventoryData`.`LENGTH(customer_po_num)` > '0' 

Solution

  • I wound up doing it like this:

    $criteria->where(
    array('`InventoryData`.`id` NOT IN (SELECT id FROM modx_gssi_inventory_data where LENGTH(customer_po_num) > 0)'));
    

    Not sure is that is the nicest way of doing it, but it works.