我很新的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()的' 如何連接? –