Example #1
0
 public function query($query, $mode = SQLDatabaseModel::MODE_ASSOC, $bind = null, $key = false)
 {
     $rows = array();
     $query = mb_convert_encoding($query, 'UTF-8', mb_detect_encoding($query));
     if (is_array($bind)) {
         $rows = Db::boundQuery($query, Db::$defaultDatabase, $bind, $mode, $key);
     } else {
         $rows = Db::query($query, Db::$defaultDatabase, $mode);
     }
     if ($rows === false) {
         $errorMessage = pg_errormessage(Db::getCachedInstance(Db::$defaultDatabase));
         Db::query("ROLLBACK", Db::$defaultDatabase);
         throw new Exception("PGSQL Says {$errorMessage} query :{$query}");
     }
     self::$namesSeen = array();
     return $rows;
 }
Example #2
0
 public function query($query, $mode = SQLDatabaseModel::MODE_ASSOC)
 {
     //$connection = Db::getCachedInstance();
     $rows = array();
     if (SQLDBDataStore::$logQueries) {
         SQLDBDataStore::log($query);
     }
     if (mb_detect_encoding($query) != 'UTF-8') {
         $query = mb_convert_encoding($query, 'UTF-8', mb_detect_encoding($query));
     }
     SQLDBDataStore::$lastQuery = $query;
     $rows = Db::query($query, Db::$defaultDatabase, $mode);
     if ($rows === false) {
         $errorMessage = pg_errormessage(Db::getCachedInstance(Db::$defaultDatabase));
         Db::query("ROLLBACK", Db::$defaultDatabase);
         throw new Exception("PGSQL Says {$errorMessage} query :{$query}");
     }
     self::$namesSeen = array();
     return $rows;
 }
Example #3
0
 public function query($query, $mode = SQLDatabaseModel::MODE_ASSOC)
 {
     $rows = array();
     if (SQLDBDataStore::$logQueries) {
         SQLDBDataStore::log($query);
     }
     if (mb_detect_encoding($query) != 'UTF-8') {
         $query = mb_convert_encoding($query, 'UTF-8', mb_detect_encoding($query));
     }
     $result = pg_query(self::$_conn, $query);
     if ($result === false) {
         pg_query(self::$_conn, "ROLLBACK");
         throw new Exception("PGSQL Says " . pg_errormessage(self::$_conn) . " [{$query}]");
     }
     switch ($mode) {
         case SQLDatabaseModel::MODE_ASSOC:
             $pgSqlMode = PGSQL_ASSOC;
             break;
         case SQLDatabaseModel::MODE_ARRAY:
             $pgSqlMode = PGSQL_NUM;
             break;
     }
     while ($row = pg_fetch_row($result, null, $pgSqlMode)) {
         $rows[] = $row;
     }
     self::$namesSeen = array();
     return $rows;
 }
Example #4
0
{
    public function select()
    {
        echo 'The class "', __METHOD__, '" was initiated!<br />';
    }
}
class Mssql extends Database
{
    public function connect()
    {
        echo 'The class "', __METHOD__, '" was initiated! User : '******' Pass : '******'<br />';
    }
    public function select()
    {
        echo 'The class "', __METHOD__, '" was initiated!<br />';
    }
}
$db = new Mysql();
$db->authentication('root', 'root');
$db->connect();
$db->select();
echo "<hr>";
$db = new Postgresql();
$db->authentication('root', 'root');
$db->connect();
$db->select();
echo "<hr>";
$db = new Mssql();
$db->authentication('ali', 'root');
$db->connect();
$db->select();