[英]Error when trying to create a table
When I use this code 当我使用此代码
CREATE TABLE $this->session->userdata('receiver_db').$receiver_table LIKE $this->session->userdata('sender_db').$sender_table
I get this message: 我收到此消息:
Object of class CI_Sessin could not be converted to string
CI_Sessin类的对象无法转换为字符串
var_dump($this->session->userdata('receiver_db')); // Returns string(14) "webprog24_reza"
var_dump($receiver_table); // Returns string(9) "guestbook"
Why am I getting this error? 为什么会出现此错误? I am trying to copy a table from one database to another.
我正在尝试将表从一个数据库复制到另一个数据库。
Setting the sessions as variables, helped me solve this problems: 将会话设置为变量,可以帮助我解决以下问题:
$db1 = $this->session->userdata('receiver_db');
$db2 = $this->session->userdata('sender_db');
$this->Connection_model->get_custom_db('receiver')->query("CREATE TABLE $db1.$receiver_table LIKE $db2.$sender_table");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.