【发布时间】:2012-10-09 16:26:37
【问题描述】:
从数据库中的一个特定表返回结果时遇到问题。
我有两张桌子:
a) repository_notes
b) repository_noteupdates (this one is giving the problem)
这是一张图片,显示两个表中都有一些数据,使用 Navicat 进行简单的 select * 查询。
但是,当我在下面查询 repository_notes 时:
print_r($this->db->get('repository_notes')->result_array());
它给了我以下结果集:
Array
(
[0] => Array
(
[note_id] => 1
[note_title] => This is my note
[note_content] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. In laoreet lobortis lacus, ac iaculis risus tristique nec. Curabitur porta gravida est, non tincidunt nunc porta nec. Nunc diam metus, feugiat non lobortis
[note_userId] => 2302
[note_pageno] => 12
[note_deleted] => 0
[note_bookid] => 12
)
[1] => Array
(
[note_id] => 2
[note_title] => This is my note
[note_content] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. In laoreet lobortis lacus, ac iaculis risus tristique nec. Curabitur porta gravida est, non tincidunt nunc porta nec. Nunc diam metus, feugiat non lobortis
[note_userId] => 2302
[note_pageno] => 12
[note_deleted] => 0
[note_bookid] => 12
)
但是当我运行下面的查询时:
print_r($this->db->get('repository_noteupdates')->result_array());
我没有得到任何结果:
Array
(
)
你们中的任何人以前是否见过这样的事情并有解决方案,我们将不胜感激。
【问题讨论】:
-
你试过类似
$sql = "SELECT * FROM repository_noteupdates"; $query = $this->db->query($sql); print_r($query->result_array()); -
我刚刚尝试过,但没有成功。但是,如果我更改为
$sql = "SELECT * FROM repository_notes"; $query = $this->db->query($sql); print_r($query->result_array());,它确实适用于另一张桌子。 @WillSampson -
尝试 print_r($this->db->last_query());并查看查询后实际查询的内容。
-
这似乎是数据库而不是 codeigniter 的问题,我会确保您的表设置正确,并且都可以从您放置在数据库配置文件中的设置访问。
-
在运行
print_r($this->db->last_query());@JohnB 之后似乎正在执行正确的查询SELECT * FROM repository_noteupdates
标签: database codeigniter activerecord