AbstractStatement.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ /xW/xE+jKV5ntgS3zfHTUNQt6FOHFy0FyL5wvuq9+YM=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.0
  11. */
  12. /**
  13. * db statement abstract class
  14. */
  15. namespace Cube\Db\Statement;
  16. use Cube\Db,
  17. Cube\Db\Adapter\AbstractAdapter;
  18. abstract class AbstractStatement implements StatementInterface
  19. {
  20. /**
  21. *
  22. * driver level statement resource
  23. *
  24. * @var resource|object
  25. */
  26. protected $_stmt = null;
  27. /**
  28. *
  29. * database adapter
  30. *
  31. * @var \Cube\Db\Adapter\AbstractAdapter
  32. */
  33. protected $_adapter = null;
  34. /**
  35. *
  36. * The current fetch mode.
  37. *
  38. * @var integer
  39. */
  40. protected $_fetchMode = Db::FETCH_ASSOC;
  41. /**
  42. *
  43. * statement attributes
  44. *
  45. * @var array
  46. */
  47. protected $_attributes = array();
  48. /**
  49. *
  50. * column result bindings
  51. *
  52. * @var array
  53. */
  54. protected $_bindColumn = array();
  55. /**
  56. *
  57. * query parameter bindings
  58. *
  59. * @var array
  60. */
  61. protected $_bindParam = array();
  62. /**
  63. *
  64. * class constructor
  65. *
  66. * @param \Cube\Db\Adapter\AbstractAdapter $adapter
  67. * @param mixed $sql a string or \Cube\Db\Select
  68. */
  69. public function __construct(AbstractAdapter $adapter, $sql)
  70. {
  71. $this->_adapter = $adapter;
  72. if ($sql instanceof Db\Select) {
  73. $sql = $sql->assemble();
  74. }
  75. $this->_prepare($sql);
  76. }
  77. /**
  78. *
  79. * the method will be implemented at the driver level
  80. *
  81. * @param mixed $sql
  82. *
  83. * @return void
  84. */
  85. protected function _prepare($sql)
  86. {
  87. return;
  88. }
  89. }