PHP - Codeigniter - 连接到PostgreSQL错误

时间:2016-04-19 08:45:03

标签: php postgresql codeigniter

我是codeigniter的新手,并将其与postgres连接。当我在登录页面填写数据并按下提交按钮时,它会显示错误。

错误号码:

ERROR: column "id" does not exist LINE 1: SELECT "id", "user_name", "user_pass" ^

SELECT "id", "user_name", "user_pass" FROM "admin" WHERE "user_name" = 'aziz' AND "user_pass" = 'aziz12' LIMIT 1

Filename: C:\wamp\www\ci_login\system\database\DB_driver.php

Line Number: 331

在codeigniter config-> database.php文件配置

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'postgres';
$db['default']['password'] = 'postgres';
$db['default']['database'] = 'login';
$db['default']['dbdriver'] = 'postgre';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$db['default']['port'] = 5432;

1 个答案:

答案 0 :(得分:0)

您的查询应该是这样的

SELECT id, user_name, user_pass FROM admin WHERE user_name = 'aziz' AND user_pass = 'aziz12' LIMIT 1

在CI中使用代码

$this->db->select("id, user_name, user_pass FROM admin");
$this->db->from("admin");
$this->db->where("user_name","aziz");
$this->db->where("user_pass","aziz12");
$this->db->limit(1);
$query = $this->db->get();
echo "<pre>";print_r($query->row_array());

由于