数据库管理操作
连接数据库
$dbms = 'mysql';
$user = 'root';
$pass = 'root';
$host = 'localhost';
$port = '3306';
$dbname = 'display';
$charset = 'utf8';
$this->dsn = "$dbms:host=$host;port=$port;dbname=$dbname;charset=$charset";
try {
return $this->pdo = new PDO($this->dsn,$user,$pass);
$this->dsn = null;
} catch (PDOException $e) {
die ("error!: " . $e->getMessage() . "<br/>");
}
查询数据库
$this->result=$this->pdo->query("select* from one");
添加新数据
$this->db->pdo->exec("insert into one (`user`,`password`) values ('$user_id','$password')");
修改数据
$this->db->pdo->exec("update one set password='$password' where user='$user_id'");