Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class myPDO {
- var $driver = 'mysql';
- var $host = 'localhost';
- var $dbname = 'database';
- var $username = 'username';
- var $password = 'password';
- var $charset = 'utf8';
- var $conn = '';
- var $stmt = '';
- var $result = '';
- function conn($driver = '', $host = '', $dbname = '', $username = '', $password = '', $charset = 'utf8') {
- $this->driver = $driver;
- $this->host = $host;
- $this->dbname = $dbname;
- $this->username = $username;
- $this->password = $password;
- $this->charset = $charset;
- $this->conn = new pdo("$this->driver:host=$this->host;dbname=$this->dbname;charset=$this->charset;", $this->username, $this->password);
- }
- function sql($sql='') {
- $this->stmt = $this->conn->prepare($sql);
- }
- function result($input=[], $fetch_style = PDO::FETCH_ASSOC) {
- $this->stmt->execute($input);
- return $this->stmt->fetchAll($fetch_style);
- }
- function row($input=[], $fetch_style = PDO::FETCH_ASSOC) {
- $this->stmt->execute($input);
- return $this->stmt->fetch($fetch_style);
- }
- }
Add Comment
Please, Sign In to add comment