note 120267 deleted from ref.pdo-mysql by cmb
| From: | cmb@php.net | Date: | Sun, 05 May 2019 15:31:39 +0000 |
| Subject: | note 120267 deleted from ref.pdo-mysql by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210976@lists.php.net to get a copy of this message | ||
Note Submitter: proyecto2016
----
A way to doing a PDORepository
<?php
abstract class PDORepository{
const USERNAME="root";
const PASSWORD="";
const HOST="localhost";
const DB="parcial";
private function getConnection(){
$username = self::USERNAME;
$password = self::PASSWORD;
$host = self::HOST;
$db = self::DB;
$connection = new PDO("mysql:dbname=$db;host=$host", $username, $password);
return $connection;
}
protected function queryList($sql, $args){
$connection = $this->getConnection();
$stmt = $connection->prepare($sql);
$stmt->execute($args);
return $stmt;
}
}
?>