Пример #1
0
 public static function QQ($dbinfo = null)
 {
     if (!$dbinfo) {
         $dbinfo = \SYSTEM\system::getSystemDBInfo();
     }
     $con = new \SYSTEM\DB\Connection($dbinfo);
     try {
         if ($dbinfo instanceof \SYSTEM\DB\DBInfoPG) {
             if (!\is_callable(static::get_class() . '::pgsql')) {
                 throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no pgsql implementation present.');
             }
             return $con->query(static::pgsql());
         } else {
             if ($dbinfo instanceof \SYSTEM\DB\DBInfoMYS) {
                 if (!\is_callable(static::get_class() . '::mysql')) {
                     throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no mysql implementation present.');
                 }
                 return $con->query(static::mysql());
             } else {
                 if ($dbinfo instanceof \SYSTEM\DB\DBInfoAMQP) {
                     if (!\is_callable(static::get_class() . '::amqp')) {
                         throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no amqp implementation present.');
                     }
                     return $con->query(static::amqp());
                 } else {
                     if ($dbinfo instanceof \SYSTEM\DB\DBInfoSQLite) {
                         if (!\is_callable(static::get_class() . '::sqlite')) {
                             throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no sqlite implementation present.');
                         }
                         return $con->query(static::sqlite());
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         throw new \Exception(static::get_class() . ' failed causing: ' . $e->getMessage(), $e->getCode(), $e);
     }
     throw new \Exception('Could not understand Database Settings. Check ur Database Settings');
 }
Пример #2
0
 public static function start($config, $short_exc = true, $short_res = true, $error_db = true, $error_json = true)
 {
     \SYSTEM\CONFIG\config::setArray($config);
     self::_start_time();
     self::_start_errorreporting();
     if ($short_exc) {
         \SYSTEM\system::include_ExceptionShortcut();
     }
     //allow ERROR() instead of \SYSTEM\LOG\ERROR()
     if ($short_res) {
         \SYSTEM\system::include_ResultShortcut();
     }
     //allow JsonResult() instead of \SYSTEM\LOG\JsonResult()
     if ($error_db) {
         \SYSTEM\system::register_errorhandler_dbwriter();
     }
     //write errors to database (must be first errorhandler to register)
     if ($error_json) {
         \SYSTEM\system::register_errorhandler_jsonoutput();
     }
     //print errors as json to caller (must be last errorhandler to register)
 }
Пример #3
0
 public function __construct(DBInfo $dbinfo = null)
 {
     if (!$dbinfo) {
         $dbinfo = \SYSTEM\system::getSystemDBInfo();
     }
     if ($dbinfo instanceof \SYSTEM\DB\DBInfoPG) {
         $this->connection = new \SYSTEM\DB\ConnectionPG($dbinfo);
     } else {
         if ($dbinfo instanceof \SYSTEM\DB\DBInfoMYS) {
             $this->connection = new \SYSTEM\DB\ConnectionMYS($dbinfo);
         } else {
             if ($dbinfo instanceof \SYSTEM\DB\DBInfoAMQP) {
                 $this->connection = new \SYSTEM\DB\ConnectionAMQP($dbinfo);
             } else {
                 if ($dbinfo instanceof \SYSTEM\DB\DBInfoSQLite) {
                     $this->connection = new \SYSTEM\DB\ConnectionSQLite($dbinfo);
                 } else {
                     throw new \Exception('Could not understand Database Settings. Check ur Database Settings');
                 }
             }
         }
     }
 }
Пример #4
0
 public static function QI($dbinfo = null)
 {
     if (!$dbinfo) {
         $dbinfo = \SYSTEM\system::getSystemDBInfo();
     }
     if ($dbinfo instanceof \SYSTEM\DB\DBInfoPG) {
         if (!\is_callable(static::get_class() . '::files_pgsql')) {
             throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no files_pgsql implementation present.');
         }
         $files = static::files_pgsql();
         $command = 'psql' . ' -U ' . $dbinfo->m_user . ' -d ' . $dbinfo->m_database . ' -a ' . ' -f ${file} 2>&1';
     } else {
         if ($dbinfo instanceof \SYSTEM\DB\DBInfoMYS) {
             if (!\is_callable(static::get_class() . '::files_mysql')) {
                 throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no files_mysql implementation present.');
             }
             $files = static::files_mysql();
             $command = 'mysql' . ' --host=' . $dbinfo->m_host . ' --user='******' --password='******' --database=' . $dbinfo->m_database . ' --default-character-set=utf8' . ' --execute="SOURCE ${file}" 2>&1';
         } else {
             if ($dbinfo instanceof \SYSTEM\DB\DBInfoAMQP) {
                 $files = static::files_amqp();
             } else {
                 if ($dbinfo instanceof \SYSTEM\DB\DBInfoSQLite) {
                     $files = static::files_sqlite();
                 } else {
                     throw new \Exception(static::get_class() . ' Could not understand Database Settings. Check ur Database Settings');
                 }
             }
         }
     }
     $result = array();
     foreach ($files as $file) {
         $output = shell_exec(str_replace('${file}', $file, $command));
         $result[] = array($file, $output);
     }
     return $result;
 }