Exemplo n.º 1
0
Arquivo: fbsql.php Projeto: roojs/pear
 /**
  * Sends a query to the database server
  *
  * @param string  the SQL query string
  *
  * @return mixed  + a PHP result resrouce for successful SELECT queries
  *                + the DB_OK constant for other successful queries
  *                + a DB_Error object on failure
  */
 function simpleQuery($query)
 {
     $this->last_query = $query;
     $query = $this->modifyQuery($query);
     $result = @fbsql_query("{$query};", $this->connection);
     if (!$result) {
         return $this->fbsqlRaiseError();
     }
     // Determine which queries that should return data, and which
     // should return an error code only.
     if ($this->_checkManip($query)) {
         return DB_OK;
     }
     return $result;
 }
 function _query($sql, $inputarr)
 {
     return fbsql_query("{$sql};", $this->_connectionID);
 }
Exemplo n.º 3
0
	function _query($sql,$inputarr=false)
	{
		return fbsql_query("$sql;",$this->_connectionID);
	}
Exemplo n.º 4
0
 /**
  * Send a query to fbsql and return the results as a fbsql resource
  * identifier.
  *
  * @param the SQL query
  *
  * @access public
  *
  * @return mixed returns a valid fbsql result for successful SELECT
  * queries, DB_OK for other successful queries.  A DB error is
  * returned on failure.
  */
 function simpleQuery($query)
 {
     $this->last_query = $query;
     $query = $this->modifyQuery($query);
     $result = @fbsql_query("{$query};", $this->connection);
     if (!$result) {
         return $this->fbsqlRaiseError();
     }
     // Determine which queries that should return data, and which
     // should return an error code only.
     if (DB::isManip($query)) {
         return DB_OK;
     }
     $numrows = $this->numrows($result);
     if (is_object($numrows)) {
         return $numrows;
     }
     $this->num_rows[$result] = $numrows;
     return $result;
 }
 /**
  * Send a query to the database and return any results
  *
  * @access public
  *
  * @param string  $query  the SQL query
  * @param mixed   $types  array that contains the types of the columns in
  *                        the result set
  *
  * @return mixed a result handle or MDB_OK on success, a MDB error on failure
  */
 function query($query, $types = NULL)
 {
     $this->debug("Query: {$query}");
     $ismanip = MDB::isManip($query);
     $this->last_query = $query;
     $first = $this->first_selected_row;
     $limit = $this->selected_row_limit;
     $this->first_selected_row = $this->selected_row_limit = 0;
     $result = $this->connect();
     if (MDB::isError($result)) {
         return $result;
     }
     if ($limit > 0) {
         if (!$ismanip) {
             $query = str_replace('SELECT', "SELECT TOP({$first},{$limit})", $query);
         }
     }
     if ($this->database_name != '') {
         if (!@fbsql_select_db($this->database_name, $this->connection)) {
             return $this->fbsqlRaiseError();
         }
     }
     // Add ; to the end of the query. This is required by FrontBase
     $query .= ';';
     if ($result = @fbsql_query($query, $this->connection)) {
         if ($ismanip) {
             $this->affected_rows = @fbsql_affected_rows($this->connection);
             return MDB_OK;
         } else {
             $result_value = intval($result);
             $this->highest_fetched_row[$result_value] = -1;
             if ($types != NULL) {
                 if (!is_array($types)) {
                     $types = array($types);
                 }
                 if (MDB::isError($err = $this->setResultTypes($result, $types))) {
                     $this->freeResult($result);
                     return $err;
                 }
             }
             return $result;
         }
     }
     return $this->fbsqlRaiseError();
 }
Exemplo n.º 6
0
 function query_fbsql($query)
 {
     if (!$this->fbsql_link) {
         return false;
     }
     $this->query_result = fbsql_query($query, $this->fbsql_link);
     if ($this->query_result) {
         return $this->query_result;
     } else {
         print nl2br("Error query. \n");
         return false;
     }
 }
Exemplo n.º 7
0
 public function query($query, $security = array())
 {
     $this->query = fbsql_query($query, $this->connect);
     return $this->query;
 }
Exemplo n.º 8
0
 /**
  * Execute a query
  * @param string $query  query
  * @param boolean $is_manip  if the query is a manipulation query
  * @param resource $connection
  * @param string $database_name
  * @return result or error object
  * @access protected
  */
 function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null)
 {
     $this->last_query = $query;
     $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
     if ($result) {
         if (MDB2::isError($result)) {
             return $result;
         }
         $query = $result;
     }
     if ($this->options['disable_query']) {
         $result = $is_manip ? 0 : null;
         return $result;
     }
     if (null === $connection) {
         $connection = $this->getConnection();
         if (MDB2::isError($connection)) {
             return $connection;
         }
     }
     if (null === $database_name) {
         $database_name = $this->database_name;
     }
     if ($database_name) {
         if ($database_name != $this->connected_database_name) {
             if (!@fbsql_select_db($database_name, $connection)) {
                 $err = $this->raiseError(null, null, null, 'Could not select the database: ' . $database_name, __FUNCTION__);
                 return $err;
             }
             $this->connected_database_name = $database_name;
         }
     }
     $result = @fbsql_query($query, $connection);
     if (!$result) {
         $err =& $this->raiseError(null, null, null, 'Could not execute statement', __FUNCTION__);
         return $err;
     }
     $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result));
     return $result;
 }
Exemplo n.º 9
0
 /**
  * Execute a query
  * @param string $query  query
  * @param boolean $is_manip  if the query is a manipulation query
  * @param resource $connection
  * @param string $database_name
  * @return result or error object
  * @access protected
  */
 function _doQuery($query, $is_manip = false, $connection = null, $database_name = null)
 {
     $this->last_query = $query;
     $this->debug($query, 'query', $is_manip);
     if ($this->options['disable_query']) {
         if ($is_manip) {
             return 0;
         }
         return null;
     }
     if (is_null($connection)) {
         $connection = $this->getConnection();
         if (PEAR::isError($connection)) {
             return $connection;
         }
     }
     if (is_null($database_name)) {
         $database_name = $this->database_name;
     }
     if ($database_name) {
         if ($database_name != $this->connected_database_name) {
             if (!@fbsql_select_db($database_name, $connection)) {
                 return $this->raiseError();
             }
             $this->connected_database_name = $database_name;
         }
     }
     $result = @fbsql_query($query, $connection);
     if (!$result) {
         return $this->raiseError();
     }
     return $result;
 }