/** * This function initializes the class. * * @access public * @override * @param DB_Connection_Driver $connection the connection to be used * @param string $sql the SQL statement to be queried * @param integer $mode the execution mode to be used * @throws Throwable_SQL_Exception indicates that the query failed */ public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL) { $resource = $connection->get_resource(); $command = @mysqli_query($resource, $sql); if ($command === FALSE) { throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @mysqli_error($resource))); } $this->command = $command; $this->record = FALSE; }
/** * This function initializes the class. * * @access public * @override * @param DB_Connection_Driver $connection the connection to be used * @param string $sql the SQL statement to be queried * @param integer $mode the execution mode to be used * @throws Throwable_SQL_Exception indicates that the query failed * * @see http://php.net/manual/en/function.sqlsrv-query.php */ public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL) { $resource = $connection->get_resource(); $command = @sqlsrv_query($resource, $sql); if ($command === FALSE) { $errors = @sqlsrv_errors(SQLSRV_ERR_ALL); $reason = (is_array($errors) and isset($errors[0]['message'])) ? $errors[0]['message'] : 'Unable to perform command.'; throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => $reason)); } $this->command = $command; $this->record = FALSE; }
/** * This function initializes the class. * * @access public * @override * @param DB_Connection_Driver $connection the connection to be used * @param string $sql the SQL statement to be queried * @param integer $mode the execution mode to be used * @throws Throwable_SQL_Exception indicates that the query failed * * @see http://www.php.net/manual/en/function.db2-prepare.php * @see http://www.php.net/manual/en/function.db2-execute.php * @see http://www.php.net/manual/en/function.db2-stmt-error.php */ public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL) { $resource = $connection->get_resource(); $command = @db2_prepare($resource, $sql); if ($command === FALSE) { throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_conn_errormsg($resource))); } if (!@db2_execute($command)) { throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_stmt_errormsg($command))); } $this->command = $command; $this->record = FALSE; }
/** * This function initializes the class. * * @access public * @override * @param DB_Connection_Driver $connection the connection to be used * @param string $sql the SQL statement to be queried * @param integer $mode the execution mode to be used * @throws Throwable_SQL_Exception indicates that the query failed */ public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL) { $this->resource = $connection->get_resource(); $command = @ibase_query($this->resource, $sql); if ($command === FALSE) { throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @ibase_errmsg())); } $this->command = $command; $this->record = FALSE; $this->blobs = array(); $count = (int) @ibase_num_fields($command); for ($i = 0; $i < $count; $i++) { $field = ibase_field_info($command, $i); if ($field['type'] == 'BLOB') { $this->blobs[] = $field['name']; } } }
/** * This function initializes the class. * * @access public * @override * @param DB_Connection_Driver $connection the connection to be used * @param string $sql the SQL statement to be queried * @param integer $mode the execution mode to be used * @throws Throwable_SQL_Exception indicates that the query failed */ public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL) { $resource = $connection->get_resource(); $command = @oci_parse($resource, trim($sql, "; \t\n\r\v")); if ($command === FALSE) { $error = @oci_error($resource); $reason = (is_array($error) and isset($error['message'])) ? $error['message'] : 'Unable to perform command.'; throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => $reason)); } if (!is_integer($mode)) { $mode = 32; } if (!oci_execute($command, $mode)) { $error = @oci_error($command); $reason = (is_array($error) and isset($error['message'])) ? $error['message'] : 'Unable to perform command.'; throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => $reason)); } $this->command = $command; $this->record = FALSE; }
/** * This function escapes a string to be used in an SQL statement. * * @access public * @override * @param string $string the string to be escaped * @param char $escape the escape character * @return string the quoted string * @throws Throwable_SQL_Exception indicates that no connection could * be found */ public function quote($string, $escape = NULL) { if (!$this->is_connected()) { throw new Throwable_SQL_Exception('Message: Failed to quote/escape string. Reason: Unable to find connection.'); } $value = @$this->resource->quote($string); if (!is_string($value)) { // check needed since ODBC does not support quoting return parent::quote($string, $escape); } if (is_string($escape) or !empty($escape)) { $value .= " ESCAPE '{$escape}'"; } return $value; }
/** * This function releases the specified connection within the connection pool. The * connection will then be allowed to close via its destructor when completely unset. * * @access public * @param DB_Connection_Driver $connection the connection to be released */ public function release(DB_Connection_Driver $connection) { if ($connection !== NULL) { $connection_id = $connection->__hashCode(); if (isset($this->lookup[$connection_id])) { $data_source_id = $this->lookup[$connection_id]; unset($this->pool[$data_source_id][$connection_id]); unset($this->lookup[$connection_id]); } } }