DataSource.php 931 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class Core_DataSource {/* TODO: abstract */
  3. var $_conn;
  4. var $_errors;
  5. var $_database_name;
  6. var $_zasob_id;
  7. public function __construct($host, $user, $password, $database, $names = '', $params = array()) {
  8. $this->_conn = null;
  9. $this->_errors = array();
  10. $this->_database_name = $database;
  11. if (!empty($params['zasob_id'])) $this->_zasob_id = $params['zasob_id'];
  12. }
  13. public function getDatabaseName() { return $this->_database_name; }
  14. public function getListByQuery($sql) {// TODO: query builder, ogc?
  15. $list = array();
  16. if (!$sql) throw new Exception("Empty query!");
  17. $res = $this->query($sql);
  18. while ($r = $this->fetch($res)) {
  19. $list[] = $r;
  20. }
  21. return $list;
  22. }
  23. public function insert($table, $data) { throw new Exception("Unimplemented Data Source function 'insert'!"); }
  24. public function getById($tableName, $id) { throw new Exception("Unimplemented Data Source function 'getById'!"); }
  25. }