21,886
社区成员
发帖
与我相关
我的任务
分享
public function dbcon(){echo $this->strdbdir.$this->username;
try {
switch($this->strdbdir){
case'userreg':
$this->dbname="cai_userdb";
$this->tbname="user_np";
$this->dbuser="xxx";
$this->dbpw="111";
$this->query="INSERT INTO $this->tbname VALUES('$this->username', '$this->password')";
echo $this->query;
break;
case'addbmf':
$this->dbname="cai_bmfdb";
$this->tbname="user_np";
$this->dbuser="yyy";
$this->dbpw="000";
}
$dsn="host=localhost;user=$this->dbuser;password=$this->dbpw";echo $dsn;
echo "a";
/********/$objPDO= new PDO($dsn);echo"b";/**********/
$objStatement=$objPDO-query($this->query);
} catch (Exception $e) {echo "error:cannot connect to db"."<br/>";
}