【问题标题】:How to debug NotORM如何调试 NotORM
【发布时间】:2016-04-20 11:47:13
【问题描述】:

有人知道调试 NotORM 请求的方法吗?

我可以通过 printf-ing NotORM 对象来获取它执行的 SQL 查询。

例子:

$models = $this->dbh->wh_product()->select("wh_model.id, wh_model.manufacturer, wh_model.model, wh_model.details, wh_model.wh_category.category, crm_contact.ragione")->order("wh_model.wh_category.id ASC, crm_contact.ragione ASC, wh_model.model ASC");

printf($models);

这给出了:

SELECT
    wh_model.id,
    wh_model.manufacturer,
    wh_model.model,
    wh_model.details,
    wh_category.category,
    crm_contact.ragione
FROM
    wh_product
LEFT JOIN wh_model ON wh_product.wh_model_id = wh_model.id
LEFT JOIN wh_category ON wh_model.wh_category_id = wh_category.id
LEFT JOIN crm_contact ON wh_product.crm_contact_id = crm_contact.id
ORDER BY
    wh_category.id ASC,
    crm_contact.ragione ASC,
    wh_model.model ASC

我遇到了这个查询的问题,因为如果我通过 phpMyAdmin 手动执行这个查询,我会得到 90 个结果,但 NotORM 只给我 14 个。

有没有办法了解 NotORM 发生了什么?

谢谢

【问题讨论】:

    标签: mysql notorm


    【解决方案1】:

    我遇到了 iterator_to_array 与结果集混淆的问题。就我而言,我正在使用

    查看结果集
    print_r(iterator_to_array($notormresult));
    

    订单被忽略了。

    我在实际迭代并打印结果集时注意到了这一点:

    $newresult = array();
    foreach($notormresult as $r){$newresult[]=iterator_to_array($r);}
    print_r($newresult);
    

    不确定这是否是您的问题,因为您的计数不匹配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多