SqlDriver.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace KarmaFW\Database\Sql;
  3. abstract class SqlDriver implements SqlDriverInterface
  4. {
  5. protected $db = null;
  6. protected $credentials = [];
  7. protected $connected = false;
  8. protected $conn = null;
  9. public function __construct($db, $credentials=null)
  10. {
  11. $this->db = $db;
  12. if (! empty($credentials)) {
  13. $this->credentials = $credentials;
  14. }
  15. }
  16. public function __debugInfo() {
  17. return [
  18. 'driver_name:protected' => $this->credentials['driver'],
  19. 'conn:protected' => get_class($this->conn) ." Object",
  20. ];
  21. }
  22. /* #### */
  23. public function connect()
  24. {
  25. // EXTENDS ME
  26. $this->conn = new \stdClass;
  27. $this->connected = true;
  28. }
  29. public function disconnect()
  30. {
  31. // EXTENDS ME
  32. $this->conn = null;
  33. $this->connected = false;
  34. }
  35. public function getInsertId()
  36. {
  37. // EXTENDS ME
  38. return null;
  39. }
  40. public function getAffectedRowsCount()
  41. {
  42. // EXTENDS ME
  43. return null;
  44. }
  45. /* #### */
  46. public function isConnected()
  47. {
  48. return $this->connected;
  49. }
  50. public function getConn()
  51. {
  52. return $this->conn;
  53. }
  54. /* #### */
  55. public function execute($query)
  56. {
  57. // EXTENDS ME
  58. return new SqlResultset(null);
  59. }
  60. }