我很新的Postgresql.what是这个错误?php pg_query()不工作?
警告:pg_query()预计参数1是资源,在C空给出:\ XAMPP \ htdocs中\ torf.php上线25
class user {
private $link=null;
private function connect() {
if ($this->link == null || !pg_ping($this->link)) {
$this->link = pg_connect("host=localhost port=5432 dbname=bigchance user=postgres password=lamp");
}
}
public function user() {
$this->connect();
}
public function new_id() {
$id=0;
$result = pg_query (user::connect(), "select * from user order by id desc limit 1 ");
if ($result != false && pg_num_rows($result>0)) {
$id= pg_fetch_result($result,0,0);
}
$id++;
return $id;
}
public function insert($email,$password) {
$id=$this->new_id();
$result=pg_query(user::connect(),"insert into user (id,email,password,ip,created_td) values ('2','{$email}','{$password}','0','0') ");
return pg_affected_rows($result);
}
}
我使用$this->connect()
但有一个错误: (
哪一行是25? –
$结果= pg_query(用户:: “按id DESC LIMIT 1 SELECT * FROM用户顺序” 连接(),); –
或 $结果= pg_query(用户::连接(),“插入用户(ID,电子邮件,密码,IP,created_td)值( '2', '{$电子邮件}', '{$密码}', '0','0')“); 我的问题: '用户:: connect()的' 如何连接? –