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'); }
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'); } } } } }
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; }