Code igniter prepending db prefix in table aliases

守給你的承諾、 提交于 2019-12-06 09:47:42

I found out that manual queries ignore table prefix. I also found out that there is a way to add table prefix to manual queries:

In config/database.php

One can do this:

$db['default']['dbprefix'] = "feed_";  
$db['default']['swap_pre'] = "{PRE}";

So that this can be done:

$sql = "SELECT * FROM {PRE}item";  
$query = $this->db->query($sql); 

The {PRE} becomes feed_.

But swap_pre is not config.php which leads me to think that this is CI 2.0 feature.

I think you should use the normal query to avoid dbprefix. Try to use $this->db->query('your query')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!