Database.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. class Core_Database {
  3. var $_conn;
  4. var $_errors;
  5. function __construct($host, $user, $password, $database, $names = '', $params = array()) {
  6. $this->_conn = null;
  7. $this->_errors = array();
  8. $this->_database_name = $database;
  9. if(!empty($params['zasob_id'])) $this->_zasob_id=$params['zasob_id'];
  10. }
  11. public function getDatabaseName() {
  12. return $this->_database_name;
  13. }
  14. /**
  15. * Wykonuje podane zapytanie i zwraca wynik mysql_query().
  16. */
  17. function query($query, $msg = 'Query ERROR.') {
  18. return null;
  19. }
  20. function fetch($res) {
  21. return null;
  22. }
  23. function _($str) {
  24. return $str;
  25. }
  26. function error() {
  27. return "#unknown";
  28. }
  29. function _set_error($err) {
  30. $this->_errors[] = $err;
  31. }
  32. function get_errors() {
  33. return $this->_errors;
  34. }
  35. function has_errors() {
  36. return !empty($this->_errors);
  37. }
  38. function get_last_error() {
  39. return end($this->_errors);
  40. }
  41. function get_by_id($table, $id) {
  42. return null;
  43. }
  44. /* @2015-04-01 - funkcja nie skonczona - gdzies jest piotrowa, ktora generuje schematy
  45. function STRUCTURE_GENERATE_to_xsd($TABLES_IMPORT,$CONNREMOTE,$schema_folder) {
  46. //
  47. // $TABLES_IMPORT - is array of tables used by $CONNREMOTE->STRUCTURE_GENERATE($TABLES_STRUCTURE,null,$TABLES_STRUCTURE_DATA)
  48. // $CONNREMOTE - is $conn of database from which we will detect its name
  49. //
  50. DEBUG_S(-3,'TABLES_IMPORT',$TABLES_IMPORT,__FILE__,__FUNCTION__,__LINE__);
  51. foreach($TABLES_IMPORT as $TABLES_IMPORT_NAME=>$TABLE_IMPORT_ARR) {
  52. if($TABLE_IMPORT_ARR['Table_type']=='BASE TABLE') {
  53. $xml = new SimpleXMLElement('<xml/>');
  54. $schema = $xml->addChild('xs:schema',null,'http://www.w3.org/2001/XMLSchema');
  55. $schema->addAttribute('xmlns:xmlns:'.$CONNREMOTE->getDatabaseName(), 'http://biuro.biall-net.pl/xmlschema_procesy5/default_db/'.$CONNREMOTE->getDatabaseName());
  56. $complexType = $schema->addChild('complexType');
  57. $complexType->addAttribute('name',$TABLES_IMPORT_NAME);
  58. $element = $complexType->addChild('element');
  59. DEBUG_S(-3,'xml output ',$xml->asXML(),__FILE__,__FUNCTION__,__LINE__);
  60. $fp = fopen($schema_folder.'/'.$TABLES_IMPORT_NAME.'.xsd', 'w');
  61. fwrite($fp, $xml->asXML());
  62. fclose($fp);
  63. }
  64. unset($xml);
  65. }
  66. }
  67. */
  68. }