作业3
来源:互联网 发布:事业单位会计软件 编辑:程序博客网 时间:2024/06/03 18:46
<?phpspl_autoload_register(function($className){ $className = str_replace("\\", "/", $className); include __DIR__ . "/" . $className . ".class.php";}); class Mysqlhelper { public $user='root'; public $host=localhost; private $password='wjy990129'; protected $connection; protected $sql; protected $dbname="test"; protected $result; public function __construct($host,$user,$password,$dbname) { $this->host=$host; $this->password=$password; $this->uesr=$user; $this->dbname=$dbname; $this->connection=new \mysqli($host,$user,$password,$dbname); } public function insert(string $ststement) { $this->sql=$statement; $this->connection->query($this->sql); if($this->connection->error) { return $this->connection->errno; } else { return $this->connection->insert_id; } } public function delete(string $ststement) { $this->sql=$statement; $this->connection->query($this->sql); if($this->connection->error) { return $this->connection->errno; } else { return $this->connection->affected_rows; } } public function update(string $ststement) { $this->sql=$statement; $this->connection->query($this->sql); if($this->connection->error) { return $this->connection->errno; } else { return $this->connection->affected_rows; } } public function select(string $ststement) { $this->sql=$statement; $result=$this->connection->query($this->sql); if($this->connection->error) { return $this->connection->errno; } else { return $result->fetch_all(MYSQLI_BOTH); } } protected function return_last_sql() { return $this->sql; } protected function return_last_result() { return $this->result; } public function __destruct() { if($this->connection) $this->connection->close() ; } } $mypdo = null;try{ $usr = 'root'; $psw = 'balabala'; $mypdo = new PDO('mysql:dbname=score;host=127.0.0.1',$usr,$psw);} catch (Exception $e) { echo $e->getMessage();}$sth1 = $mypdo->prepare($statement);$id = "5";$sth1->bindParam(":id", $id);$sth1->execute();var_dump($sth1->fetchAll(PDO::FETCH_ASSOC));
阅读全文
0 0
- 作业:C++作业3
- 作业:C++作业3
- 作业:C++作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- 作业3
- codeforces 276D Little Girl and Maximum XOR(区间最大异或值--技巧)【模板】
- 坑题
- php ajax 点击'查看更多'小功能
- 51nod 1396 还是01串 【思维题】
- 关于二进制位移“>>”和“>>>”的区别小结
- 作业3
- C#基础(3)——异常捕获与断点调试
- 分布式ID生成器
- nodejs异常之-Error: listen EACCES 127.0.0.1:8000
- 牛客网初级项目课第一节
- linux shell之tput和stty
- HashMap、HashTable、ConcurrentHashMap
- Binary Search:81. Search in Rotated Sorted Array II
- 使用solidworks插件获取urdf包