【问题标题】:inserting data into postgresql database with codeigniter使用codeigniter将数据插入postgresql数据库
【发布时间】:2014-11-02 23:27:42
【问题描述】:

当我尝试在 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")。

你知道我怎样才能避免这种情况吗?我只想输入没有表名的字段名称。

提前致谢! =)

【问题讨论】:

  • 外键关系错误?
  • 你的 $data 是什么样的?
  • Banzilla- 这不是外键错误,@Shaiful Islam- 我的变量 $data 是一个数组:$data =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,);
  • @DeutscheMexa 您能否在问题中包含表user_accounts 的DDL?这样我们就可以想出一个更相关的答案。

标签: php database postgresql codeigniter


【解决方案1】:

您是否检查过 "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        
    );

【讨论】:

  • 是的,我之前检查过,它正确获取了所有值,但问题是 postgresql 将此表名作为列名,因此无法识别。
猜你喜欢
  • 2013-04-04
  • 2016-09-18
  • 2014-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-04
相关资源
最近更新 更多