Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SQL {
- protected $handler;
- protected $hostname = 'localhost';
- protected $password = '';
- protected $username = 'root';
- protected $dbname = 'test';
- public function __construct() {
- try {
- $this->handler = new PDO("mysql:host={$this->hostname};dbname={$this->dbname}", $this->username, $this->password);
- }
- catch(PDOException $e) {
- echo $e->getMessage();
- }
- }
- public function insert($table,$rows,$values){
- return $this->handler->exec("INSERT INTO ".$table."(".$rows.") VALUES ('".$values."')");
- }
- }
- $sql = new SQL();
- $sql->insert("users", "username,password", "'hisham', 'startimes'");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement