Advertisement
Guest User

Untitled

a guest
Mar 26th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. class dbFunctions {
  2.  
  3. private $userSelect = "userSelect";
  4. private $passSelect = "XXXXX";
  5. private $userDelete = "userDelete";
  6. private $passDelete = "XXXXX";
  7.  
  8. protected function connectSelect() {
  9. $dsn = $this->dsn();
  10. $this->pdo = new PDO($dsn, $this->userSelect, $this->passSelect, $this->options);
  11.  
  12. return $this->pdo;
  13. }
  14.  
  15. protected function connectDelete() {
  16. $dsn = $this->dsn();
  17. $this->pdo = new PDO($dsn, $this->userDelete, $this->passDelete, $this->options);
  18.  
  19. return $this->pdo;
  20. }
  21.  
  22. public function selectCount($query, $values = []) {
  23.  
  24. $result = $this->connectSelect()->prepare($query);
  25. $result->execute($values);
  26. $exec = $result->fetch();
  27.  
  28. $count = (int)$exec['total'];
  29.  
  30. return $count;
  31. }
  32. }
  33.  
  34. class dbFunctions {
  35.  
  36. private $userSelect = "userSelect";
  37. private $passSelect = "XXXXX";
  38. private $userDelete = "userDelete";
  39. private $passDelete = "XXXXX";
  40.  
  41. private $selectInstance = null;
  42. private $deleteInstance = null;
  43.  
  44. protected function connectSelect() {
  45. if ($this->selectInstance === null) {
  46. $dsn = $this->dsn();
  47. $this->selectInstance = new PDO($dsn, $this->userSelect, $this->passSelect, $this->options);
  48. }
  49. return $this->selectInstance;
  50. }
  51.  
  52. protected function connectDelete() {
  53. if ($this->deleteInstance === null) {
  54. $dsn = $this->dsn();
  55. $this->deleteInstance = new PDO($dsn, $this->userDelete, $this->passDelete, $this->options);
  56. }
  57. return $this->deleteInstance;
  58. }
  59.  
  60. public function selectCount($query, $values = []) {
  61.  
  62. $result = $this->connectSelect()->prepare($query);
  63. $result->execute($values);
  64. $exec = $result->fetch();
  65.  
  66. $count = (int)$exec['total'];
  67.  
  68. return $count;
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement