在mysql中我可以查询如下:
select studentname,'student' as profession from students
它返回如下内容:
studentname | profession
------------+-----------
name1 | student
name2 | student
...
但是我如何在使用事件记录的 codeigniter 中这样做呢?我是 CI 的新手,非常感谢您的帮助。
注意:为了澄清我的问题,学生表中没有名为 student
或 profession
的列。 student
是我希望在我的结果集中包含的固定文本。
如果我查询类似:
$this->db->select("studentname, student as profession")->from('students')
然后它会给出错误,因为它试图找到学生列,而它只是一个静态值。
最佳答案
select 有第二个选项。将其设置为 false 并尝试 -
$this->db->select('studentname, "student" as profession', false)->from('students')
关于mysql - codeigniter 事件记录建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10744945/