コード例 #1
0
ファイル: MDB2.php プロジェクト: BackupTheBerlios/wcms
 /**
  * Send a query to the database and return any results
  *
  * @param string $query the SQL query
  * @param mixed   $types  array that contains the types of the columns in
  *                        the result set
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  * @access public
  */
 function &query($query, $types = null, $result_class = true, $result_wrap_class = false)
 {
     $isManip = MDB2::isManip($query);
     $offset = $this->row_offset;
     $limit = $this->row_limit;
     $this->row_offset = $this->row_limit = 0;
     $query = $this->_modifyQuery($query, $isManip, $limit, $offset);
     $connected = $this->connect();
     if (PEAR::isError($connected)) {
         return $connected;
     }
     $result = $this->_doQuery($query, $isManip, $this->connection, $this->database_name);
     if (PEAR::isError($result)) {
         return $result;
     }
     if ($isManip) {
         return $result;
     }
     return $this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset);
 }
コード例 #2
0
ファイル: peardb.php プロジェクト: BackupTheBerlios/wcms
 function isManip($query)
 {
     return MDB2::isManip($query);
 }
コード例 #3
0
ファイル: sqlite.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * Send a query to the database and return any results
  *
  * @param string  $query  the SQL query
  * @param mixed   $types  string or array that contains the types of the
  *                        columns in the result set
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  *
  * @access public
  */
 function &query($query, $types = null, $result_class = false, $result_wrap_class = false)
 {
     $ismanip = MDB2::isManip($query);
     $offset = $this->row_offset;
     $limit = $this->row_limit;
     $this->row_offset = $this->row_limit = 0;
     if ($limit > 0) {
         if ($ismanip) {
             $query .= " LIMIT {$limit}";
         } else {
             $query .= " LIMIT {$limit} OFFSET {$offset}";
         }
     }
     if ($this->options['portability'] & MDB2_PORTABILITY_DELETE_COUNT) {
         $query = $this->_modifyQuery($query);
     }
     $this->last_query = $query;
     $this->debug($query, 'query');
     $connected = $this->connect();
     if (MDB2::isError($connected)) {
         return $connected;
     }
     $function = $this->options['result_buffering'] ? 'sqlite_query' : 'sqlite_unbuffered_query';
     ini_set('track_errors', true);
     $result = @$function($query . ';', $this->connection);
     ini_restore('track_errors');
     $this->_lasterror = isset($php_errormsg) ? $php_errormsg : '';
     if ($result) {
         if ($ismanip) {
             return MDB2_OK;
         } else {
             if (!$result_class) {
                 $result_class = $this->options['result_buffering'] ? $this->options['buffered_result_class'] : $this->options['result_class'];
             }
             $class_name = sprintf($result_class, $this->phptype);
             $result =& new $class_name($this, $result);
             if ($types) {
                 $err = $result->setResultTypes($types);
                 if (MDB2::isError($err)) {
                     $result->free();
                     return $err;
                 }
             }
             if (!$result_wrap_class) {
                 $result_wrap_class = $this->options['result_wrap_class'];
             }
             if ($result_wrap_class) {
                 $result =& new $result_wrap_class($result);
             }
             return $result;
         }
     }
     $error =& $this->raiseError();
     return $error;
 }
コード例 #4
0
ファイル: mssql.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * Send a query to the database and return any results
  *
  * @param string  $query  the SQL query
  * @param mixed   $types  array that contains the types of the columns in
  *                        the result set
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  *
  * @access public
  */
 function &query($query, $types = null, $result_class = false, $result_wrap_class = false)
 {
     $ismanip = MDB2::isManip($query);
     $offset = $this->row_offset;
     $limit = $this->row_limit;
     $this->row_offset = $this->row_limit = 0;
     if ($limit > 0) {
         $fetch = $offset + $limit;
         if (!$ismanip) {
             $query = str_replace('SELECT', "SELECT TOP {$fetch}", $query);
         }
     }
     $this->last_query = $query;
     $this->debug($query, 'query');
     $connected = $this->connect();
     if (MDB2::isError($connected)) {
         return $connected;
     }
     if ($this->database_name) {
         if (!@mssql_select_db($this->database_name, $this->connection)) {
             $error =& $this->raiseError();
             return $error;
         }
         $this->connected_database_name = $this->database_name;
     }
     if ($result = $this->_doQuery($query)) {
         if ($ismanip) {
             return MDB2_OK;
         } else {
             if (!$result_class) {
                 $result_class = $this->options['result_buffering'] ? $this->options['buffered_result_class'] : $this->options['result_class'];
             }
             $class_name = sprintf($result_class, $this->phptype);
             $result =& new $class_name($this, $result, $offset, $limit);
             if ($types) {
                 $err = $result->setResultTypes($types);
                 if (MDB2::isError($err)) {
                     $result->free();
                     return $err;
                 }
             }
             if (!$result_wrap_class) {
                 $result_wrap_class = $this->options['result_wrap_class'];
             }
             if ($result_wrap_class) {
                 $result =& new $result_wrap_class($result);
             }
             return $result;
         }
     }
     $error =& $this->raiseError();
     return $error;
 }
コード例 #5
0
ファイル: oci8.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * Execute a prepared query statement.
  *
  * @param int $prepared_query argument is a handle that was returned by
  *       the function prepare()
  * @param string $query query to be executed
  * @param array $types array that contains the types of the columns in the result set
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  *
  * @access private
  */
 function &_executePrepared($prepared_query, $query, $types = null, $result_class = false, $result_wrap_class = false)
 {
     $ismanip = MDB2::isManip($query);
     $offset = $this->row_offset;
     $limit = $this->row_limit;
     $this->row_offset = $this->row_limit = 0;
     $query = $this->_modifyQuery($query);
     $this->last_query = $query;
     $this->debug($query, 'query');
     $connected = $this->connect();
     if (MDB2::isError($connected)) {
         return $connected;
     }
     $result = $this->_doQuery($query, $ismanip, $prepared_query);
     if (!MDB2::isError($result)) {
         if ($ismanip) {
             return MDB2_OK;
         } else {
             if (!$result_class) {
                 $result_class = $this->options['result_buffering'] ? $this->options['buffered_result_class'] : $this->options['result_class'];
             }
             $class_name = sprintf($result_class, $this->phptype);
             $result =& new $class_name($this, $result, $offset, $limit);
             if ($types) {
                 $err = $result->setResultTypes($types);
                 if (MDB2::isError($err)) {
                     $result->free();
                     return $err;
                 }
             }
             if (!$result_wrap_class) {
                 $result_wrap_class = $this->options['result_wrap_class'];
             }
             if ($result_wrap_class) {
                 $result =& new $result_wrap_class($result);
             }
             return $result;
         }
     }
     return $result;
 }
コード例 #6
0
ファイル: pgsql.php プロジェクト: BackupTheBerlios/smart-svn
 /**
  * Send a query to the database and return any results
  *
  * @param string $query the SQL query
  * @param array $types array that contains the types of the columns in
  *                         the result set
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  *
  * @access public
  */
 function &query($query, $types = null, $result_class = false, $result_wrap_class = false)
 {
     $ismanip = MDB2::isManip($query);
     $offset = $this->row_offset;
     $limit = $this->row_limit;
     $this->row_offset = $this->row_limit = 0;
     $this->last_query = $query;
     $this->debug($query, 'query');
     $connected = $this->connect();
     if (MDB2::isError($connected)) {
         return $connected;
     }
     if (!$ismanip && $limit > 0) {
         if ($this->auto_commit && MDB2::isError($result = $this->_doQuery('BEGIN'))) {
             return $result;
         }
         $result = $this->_doQuery('DECLARE select_cursor SCROLL CURSOR FOR ' . $query);
         if (!MDB2::isError($result)) {
             if ($offset > 0 && MDB2::isError($result = $this->_doQuery("MOVE FORWARD {$offset} FROM select_cursor"))) {
                 @pg_free_result($result);
                 return $result;
             }
             $result = $this->_doQuery("FETCH FORWARD {$limit} FROM select_cursor");
             if (MDB2::isError($result)) {
                 @pg_free_result($result);
                 return $result;
             }
         } else {
             return $result;
         }
         if ($this->auto_commit && MDB2::isError($result2 = $this->_doQuery('END'))) {
             @pg_free_result($result);
             return $result2;
         }
     } else {
         $result = $this->_doQuery($query);
         if (MDB2::isError($result)) {
             return $result;
         }
     }
     if (!MDB2::isError($result)) {
         if ($ismanip) {
             $this->affected_rows = @pg_cmdtuples($result);
             return MDB2_OK;
         } elseif (preg_match('/^\\s*\\(?\\s*SELECT\\s+/si', $query) && !preg_match('/^\\s*\\(?\\s*SELECT\\s+INTO\\s/si', $query) || preg_match('/^\\s*EXPLAIN/si', $query)) {
             if (!$result_class) {
                 $result_class = $this->options['result_buffering'] ? $this->options['buffered_result_class'] : $this->options['result_class'];
             }
             $class_name = sprintf($result_class, $this->phptype);
             $result =& new $class_name($this, $result);
             if ($types) {
                 $err = $result->setResultTypes($types);
                 if (MDB2::isError($err)) {
                     $result->free();
                     return $err;
                 }
             }
             if (!$result_wrap_class) {
                 $result_wrap_class = $this->options['result_wrap_class'];
             }
             if ($result_wrap_class) {
                 $result =& new $result_wrap_class($result);
             }
             return $result;
         } else {
             $this->affected_rows = 0;
             return MDB2_OK;
         }
     }
     return $result;
 }
コード例 #7
0
ファイル: mysql.php プロジェクト: BackupTheBerlios/smart-svn
 /**
  * Send a query to the database and return any results
  *
  * @param string  $query  the SQL query
  * @param mixed   $types  string or array that contains the types of the
  *                        columns in the result set
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  *
  * @access public
  */
 function &query($query, $types = null, $result_class = false, $result_wrap_class = false)
 {
     $ismanip = MDB2::isManip($query);
     $offset = $this->row_offset;
     $limit = $this->row_limit;
     $this->row_offset = $this->row_limit = 0;
     if ($limit > 0) {
         if ($ismanip) {
             $query .= " LIMIT {$limit}";
         } else {
             $query .= " LIMIT {$offset},{$limit}";
         }
     }
     if ($this->options['portability'] & MDB2_PORTABILITY_DELETE_COUNT) {
         $query = $this->_modifyQuery($query);
     }
     $this->last_query = $query;
     $this->debug($query, 'query');
     $connected = $this->connect();
     if (MDB2::isError($connected)) {
         return $connected;
     }
     if ($this->database_name && $this->database_name != $this->connected_database_name) {
         if (!@mysql_select_db($this->database_name, $this->connection)) {
             $error =& $this->raiseError();
             return $error;
         }
         $this->connected_database_name = $this->database_name;
     }
     $function = $this->options['result_buffering'] ? 'mysql_query' : 'mysql_unbuffered_query';
     if ($result = @$function($query, $this->connection)) {
         if ($ismanip) {
             return MDB2_OK;
         } else {
             if (!$result_class) {
                 $result_class = $this->options['result_buffering'] ? $this->options['buffered_result_class'] : $this->options['result_class'];
             }
             $class_name = sprintf($result_class, $this->phptype);
             $result =& new $class_name($this, $result);
             if ($types) {
                 $err = $result->setResultTypes($types);
                 if (MDB2::isError($err)) {
                     $result->free();
                     return $err;
                 }
             }
             if (!$result_wrap_class) {
                 $result_wrap_class = $this->options['result_wrap_class'];
             }
             if ($result_wrap_class) {
                 $result =& new $result_wrap_class($result);
             }
             return $result;
         }
     }
     $error =& $this->raiseError();
     return $error;
 }