StorageBase.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. // Lib::loadClass('Core_StorageObject');
  3. // Lib::loadClass('Core_StorageField');
  4. class Core_StorageBase {
  5. protected $_zasob_id = 0;
  6. protected $_cache = array();
  7. public function __construct($pdo) {
  8. throw new Exception("Storage constructor not defined");
  9. }
  10. public function fetchAllAssoc($sql) {
  11. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  12. }
  13. public function getZasobId() {
  14. return $this->_zasob_id;
  15. }
  16. public function getType() {
  17. return $this->_pdo->getType();
  18. }
  19. // public function getObject($tableName) {
  20. // $storageZasobId = $this->getZasobId();
  21. // $storageObject = new Core_StorageObject("{$storageZasobId}/{$tableName}");
  22. // $tableStruct = $this->getTableStruct($tableName);
  23. // $pkFieldName = null;
  24. // foreach ($tableStruct as $fldName => $vFldType) {
  25. // $vField = new Core_StorageField("{$storageZasobId}/{$tableName}/{$fldName}");
  26. // $vField->setName($fldName);
  27. // $storageObject->setField($vField);
  28. // if ($vFldType->isPrimaryKey()) {
  29. // $pkFieldName = $fldName;
  30. // }
  31. // }
  32. // if ($pkFieldName) {
  33. // $storageObject->setPrimaryKeyFieldName($pkFieldName);
  34. // }
  35. // return $storageObject;
  36. // }
  37. public function getTableStruct($tableName) {
  38. $storageZasobId = $this->getZasobId();
  39. $tblUri = "{$storageZasobId}/{$tableName}";
  40. if (!array_key_exists($tblUri, $this->_cache)) {
  41. $this->_cache[$tblUri] = $this->_getTableStruct($tableName);
  42. }
  43. return $this->_cache[$tblUri];
  44. }
  45. protected function _getTableStruct($tableName) {
  46. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  47. }
  48. public function getTableStructRaw($tableName) {
  49. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  50. }
  51. public function getTableList() {
  52. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  53. }
  54. public function getViewStruct($viewName) {
  55. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  56. }
  57. public function getViewStructRaw($viewName) {
  58. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  59. }
  60. public function getViewList() {
  61. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  62. }
  63. public function getTableListWithInfo() {
  64. throw new Exception("Storage " . __FUNCTION__ . " not defined");
  65. }
  66. }