コード例 #1
0
ファイル: r3impexp.php プロジェクト: r3-gis/EcoGIS
 /**
  * Connect to database by using the given DSN string, to get the authentication method
  *
  * @access protected
  * @param  string DSN string
  * @return mixed  Object on error, otherwise bool
  */
 protected function dbConnect($db, $opt)
 {
     if (is_string($db) || is_array($db)) {
         $this->log(LOG_DEBUG, 'Connecting to database');
         $this->db =& MDB2::connect($db);
     } elseif (is_subclass_of($db, 'MDB2_Driver_Common')) {
         $this->db = $db;
     } else {
         throw new Exception('Invalid DSN or connection');
     }
     checkDBError($this->db, __LINE__);
 }
コード例 #2
0
ファイル: r3import_utils.php プロジェクト: r3-gis/EcoGIS
 public function getTemporaryTablesByAge($seconds)
 {
     $tables = array();
     if ($this->options['dbtype'] == 'pgsql') {
         $sql = sprintf("SELECT it_table from %s.%s \n" . "WHERE it_date + INTERVAL '%s seconds' < CURRENT_TIMESTAMP FOR UPDATE", $this->options['schema'], IMPORT_SYSTEM_TABLE_NAME, $seconds);
     } else {
         if ($this->options['dbtype'] == 'oracle') {
             $sql = sprintf("SELECT it_table from %s.%s \n" . "WHERE it_date + INTERVAL '%s' SECOND < CURRENT_TIMESTAMP", $this->options['schema'], IMPORT_SYSTEM_TABLE_NAME, $seconds);
         } else {
             throw new Exception("database {$this->options['dbtype']} not supported");
         }
     }
     $res = $this->db->query($sql);
     checkDBError($res, __LINE__);
     while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
         $tables[] = $row['it_table'];
     }
     $res->free();
     return $tables;
 }
コード例 #3
0
ファイル: index.php プロジェクト: jhubert/php-invoice
function addAdminAccount()
{
    require_once 'DB.php';
    $TC = new TypicalConfig(SITE_ROOT . 'includes/config.php');
    $TC->loadConfig();
    $config = $TC->getVars('var');
    unset($TC);
    $dsn = $config['db_type'] . "://" . $config['db_user'] . ":" . $config['db_pass'] . "@" . $config['db_host'] . "/" . $config['db_name'];
    $check = acquireConnection($db, $dsn);
    if (!$check) {
        $db_prefix = $config['db_prefix'];
        include 'sql_admin.php';
        echo "<p>Inserting Admin Account...";
        $error = array();
        $result = $db->query($sql);
        $err = checkDBError($result);
        if ($err) {
            $error[] = $err . " ::> " . $sql;
            echo '<span class="check_fail">FAILED!</span></p><p>The error message was:<b> ' . $err . '</b><br>on the query:<br>' . $sql;
            die;
        }
        echo '<span class="check_pass">DONE!</span></p>';
        releaseConnection($db);
        return true;
    }
    return false;
}
コード例 #4
0
ファイル: functions.php プロジェクト: jhubert/php-invoice
function testConnection(&$db)
{
    global $table_prefix;
    $query = "SELECT count(*) FROM {$table_prefix}client";
    $db->getOne($query);
    checkDBError($db);
    return true;
}
コード例 #5
0
ファイル: pgsql.php プロジェクト: r3-gis/EcoGIS
 function getTableForeignKeyList($table, $opt = array())
 {
     $sql = $this->getTableForeignKeyListDDL($table, $opt);
     $result = array();
     $pattern = "/FOREIGN KEY \\(([a-zA-Z_0-9,\\s]+)\\) REFERENCES (([a-zA-Z_0-9]+)\\.){0,1}([a-zA-Z_0-9]+)\\(([a-zA-Z_0-9,\\s]+)\\)/";
     $name = $this->extractTableDesc($table);
     $res = $this->db->query($sql);
     checkDBError($res, __LINE__);
     while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
         preg_match($pattern, $row['condef'], $a);
         $result[$row['conname']] = array('table' => "{$name['schema']}.{$name['table']}", 'fields' => explode(',', str_replace(' ', '', $a[1])), 'foreign_table' => ($a[3] == '' ? $name['schema'] : $a[3]) . '.' . $a[4], 'foreign_fields' => explode(',', str_replace(' ', '', $a[5])));
     }
     return $result;
 }