使用codeigniter将数据插入postgresql数据库

时间:2014-11-02 23:27:43

标签: php database postgresql codeigniter

当我尝试在postgresql中的用户表中插入一行时遇到问题,例如

我有正常的插入活动记录,$ this-> db-> insert($ table,$ data)我得到的错误是这样的:

错误:“user_accounts”关系中的列“user_accounts”不存在。第1行:INSERT INTO“user_accounts”(“user_accounts”。“uacc_group_fk”

我认为问题可能是我要插入的字段中的表名(“user_accounts”。“uacc_group_fk”),.

你知道我怎么能避免这种情况?我只想把没有表名的字段名称。

提前致谢! =)

1 个答案:

答案 0 :(得分:0)

您是否检查过“user_accounts”列。“uacc_group_fk”是否存在(带引号)?

这是https://github.com/haseydesign/flexi-auth/blob/master/library_files/application/models/flexi_auth_model.php的insert_user功能中使用的数据数组:

$sql_insert = array(
        $this->auth->tbl_col_user_account['group_id'] => $group_id,
        $this->auth->tbl_col_user_account['email'] => $email,
        $this->auth->tbl_col_user_account['username'] => ($username) ? $username : '',
        $this->auth->tbl_col_user_account['password'] => $hash_password,
        $this->auth->tbl_col_user_account['ip_address'] => $ip_address,
        $this->auth->tbl_col_user_account['last_login_date'] => $this->database_date_time(),
        $this->auth->tbl_col_user_account['date_added'] => $this->database_date_time(),
        $this->auth->tbl_col_user_account['activation_token'] => $activation_token,
        $this->auth->tbl_col_user_account['active'] => 0,       
        $this->auth->tbl_col_user_account['suspend'] => $suspend_account        
    );