【问题标题】:Codeigniter activerecord query continuously runsCodeigniter activerecord 查询连续运行
【发布时间】:2014-06-14 02:55:22
【问题描述】:

当我尝试运行以下查询时,它从不返回任何内容,它只是继续运行。我做错了什么?

$this->db->distinct('customer.Name')
                    ->from('customer')
                    ->from('invoicelinedetail')
                    ->from('invoice')
                    ->from('iteminventory')
                    ->where('invoice.CustomerRef_ListID = customer.ListID')
                    ->where('invoicelinedetail.IDKEY = invoice.TxnID')
                    ->where('invoicelinedetail.ItemRef_ListID =', $id)
                    ->order_by('customer.Name', 'desc');
$query = $this->db->get();

【问题讨论】:

  • 我不认为distinct() 接受任何参数。我认为您需要这样做:->distinct()->select('customer.Name')。我也不确定您是否可以多次致电->from(),尝试->from('customer, invoicelinedetail, ...') 或使用->join()。不过,我可能 100% 错了。
  • 另外,“t just keep running”是什么意思?您的意思是页面永远不会在您的浏览器中加载?
  • 一个模型方法 mut 也会返回一些东西 :) 尝试在查询上使用 return 来查看它返回一个对象。使用下面@Dan 的答案来提取你想要的。
  • 我实际上得到了与模型不一致的数据。不过,我现在正在尝试不同的方式。火箭危险品:没错。该页面永远不会加载。

标签: php codeigniter activerecord mysqli-multi-query


【解决方案1】:

$this->db->get(); 之后你需要检索你的结果

More info from CI Docs

为此,请将$query= 设置为以下之一:

$this->db->result_array(); //returns array
$this->db->row_array(); //returns single row as array

$this->db->result(); //returns object
$this->db->row(); //returns single row as object

【讨论】:

  • 我会尽快试一试。谢谢,丹!
  • 明白了。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-07
相关资源
最近更新 更多