如何在推进中添加与子字符串的连接

How to add join with substring in propel

我有以下 SQL 查询

SELECT *
FROM inventory_audits
WHERE id in (
SELECT distinct inventory_audits.id
FROM inventory_audits
LEFT JOIN pick_lists ON (pick_lists.number = substr(inventory_audits.reference,0,8))
LEFT JOIN pick_list_items ON (pick_list_items.pick_list_id = pick_lists.id)
LEFT JOIN load_plan_items ON (load_plan_items.load_plan_id = pick_list_items.load_plan_id)
LEFT JOIN sales_order_items ON (load_plan_items.sales_order_item_id = sales_order_items.id)
LEFT JOIN invoices ON (invoices.id = sales_order_items.invoice_id)
WHERE inventory_adjustment_reason_description = 'Picked' 
AND (invoices.number = '230367' OR invoices.number = '230368')
)

而且,我需要将其转换为推动结果为

$cr = new Criteria();
$cr->addJoin(PickListPeer::ID, PickListItemPeer::PICK_LIST_ID);
$cr->addJoin(PickListItemPeer::LOAD_PLAN_ID, LoadPlanItemPeer::LOAD_PLAN_ID);
$cr->addJoin(LoadPlanItemPeer::SALES_ORDER_ITEM_ID, SalesOrderItemPeer::ID);
$cr->addJoin(SalesOrderItemPeer::INVOICE_ID, InvoicePeer::ID);
$cr->add(InventoryAuditPeer::INVENTORY_ADJUSTMENT_REASON_DESCRIPTION, 'Picked');
$cr->add(InvoicePeer::NUMBER, $invoiceNumbers, Criteria::IN);
$cr->setDistinct(true);

但是我有点困惑如何转换这个连接推进...

LEFT JOIN pick_lists ON (pick_lists.number = substr(inventory_audits.reference,0,8))

,我试过了但没用..

$cr->add(PickListPeer::NUMBER, substr(InventoryAuditPeer::REFERENCE, 0, 8));

我使用的是 propel 1.2.1 感谢任何参考:) tyvm..

Nvm,我用这条线让它工作了..

$cr->addJoin('substr(inventory_audits.REFERENCE, 0, 8)', PickListPeer::NUMBER, Criteria::LEFT_JOIN);