Codeigniter 插入数据 MSSQL [英] Codeigniter Insert Data MSSQL

查看:37
本文介绍了Codeigniter 插入数据 MSSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用多个数据库的网站,它同时使用 MSSQL 和 MYSQL,但我不不知道为什么插入数据不起作用.我在下面有 2 个代码示例:

I am working website with multiple database and it use both MSSQL and MYSQL but I dont why insert data wont work. I have 2 codes sample below:

第一个模型代码

$this->mssqlu->insert('tbl_account', array('id ' => CONVERT(BINARY(16),$username, 1), 'password' => CONVERT(BINARY(16),$password, 1), 'Email' => $email, 'accounttype' =>0, 'birthdate' => '2011-11-11 00:00:00','pin' => $pin, 'fb_id' => $fb_id ));
    return $this->mssqlu->insert_id();

第二个模型代码

 $lu_sql = sprintf("INSERT INTO tbl_account (id,password,Email,accounttype,birthdate,pin,fb_id) VALUES ((CONVERT (binary,$username)),(CONVERT (binary,$password)),$email,0,'2011-11-11 00:00:00',$pin,$fb_id)");
    $query = $this->mssqlu->query($lu_sql);
    return $query;

推荐答案

 $data=array('id ' => CONVERT(BINARY(16),$username, 1), 'password' => 
              CONVERT(BINARY(16),$password, 1), 'Email' => $email, 'accounttype' 
             =>0,'birthdate' => '2011-11-11 00:00:00','pin' => $pin, 'fb_id' => 
             $fb_id );
        

return (($this->mssqlu->insert('tbl_account', $data)) ? $this->mssqlu->insert_id() : False);

return (($this->mssqlu->insert('tbl_account', $data)) ? $this->mssqlu->insert_id() : False);

这篇关于Codeigniter 插入数据 MSSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆