本文整理汇总了PHP中ibase_prepare函数的典型用法代码示例。如果您正苦于以下问题:PHP ibase_prepare函数的具体用法?PHP ibase_prepare怎么用?PHP ibase_prepare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ibase_prepare函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_logo
function save_logo()
{
$dbh = $this->db->conn_id;
$fileName1 = $_FILES['image']['name'];
$filename = './uploads/tmp/' . $fileName1;
$fd = fopen($filename, 'r');
if ($fd) {
$blob = ibase_blob_import($dbh, $fd);
fclose($fd);
if (!is_string($blob)) {
// import failed
echo "Gagal Import File";
} else {
$query = "UPDATE PEMDA SET LOGO = ?";
$prepared = ibase_prepare($dbh, $query);
if (!ibase_execute($prepared, $blob)) {
// record update failed
echo "Gagal Simpan Logo";
}
}
} else {
// unable to open the data file
echo "Tidak dapat membuka data";
}
}
示例2: _prepare
/**
* @param string $sql
* @return void
* @throws Zend_Db_Statement_Firebird_Exception
*/
public function _prepare($sql)
{
$connection = $this->_adapter->getConnection();
if ($trans = $this->_adapter->getTransaction()) {
$this->_stmt_prepared = @ibase_prepare($connection, $trans, $sql);
} else {
$this->_stmt_prepared = @ibase_prepare($connection, $sql);
}
if ($this->_stmt_prepared === false || ibase_errcode()) {
/**
* @see Zend_Db_Statement_Firebird_Exception
*/
require_once 'Zend/Db/Statement/Firebird/Exception.php';
throw new Zend_Db_Statement_Firebird_Exception("Firebird prepare error: " . ibase_errmsg());
}
}
示例3: prepare
public function prepare($sql)
{
if (!$this->is_connected()) {
$this->connect();
}
return ibase_prepare($this->lnk, $sql);
}
示例4: sql_query
/**
* Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/
function sql_query($query = '', $cache_ttl = 0)
{
if ($query != '') {
global $cache;
// EXPLAIN only in extra debug mode
if (defined('DEBUG_EXTRA')) {
$this->sql_report('start', $query);
}
$this->last_query_text = $query;
$this->query_result = $cache_ttl && method_exists($cache, 'sql_load') ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) {
$array = array();
// We overcome Firebird's 32767 char limit by binding vars
if (strlen($query) > 32767) {
if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/s', $query, $regs)) {
if (strlen($regs[3]) > 32767) {
preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);
$inserts = $vals[0];
unset($vals);
foreach ($inserts as $key => $value) {
if (!empty($value) && $value[0] === "'" && strlen($value) > 32769) {
$inserts[$key] = '?';
$array[] = str_replace("''", "'", substr($value, 1, -1));
}
}
$query = $regs[1] . '(' . $regs[2] . ') VALUES (' . implode(', ', $inserts) . ')';
}
} else {
if (preg_match('/^(UPDATE ([\\w_]++)\\s+SET )([\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|\\d+)(?:,\\s*[\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\\d-.]+))*+)\\s+(WHERE.*)$/s', $query, $data)) {
if (strlen($data[3]) > 32767) {
$update = $data[1];
$where = $data[4];
preg_match_all('/(\\w++)\\s*=\\s*(\'(?:[^\']++|\'\')*+\'|[\\d-.]++)/', $data[3], $temp, PREG_SET_ORDER);
unset($data);
$cols = array();
foreach ($temp as $value) {
if (!empty($value[2]) && $value[2][0] === "'" && strlen($value[2]) > 32769) {
$array[] = str_replace("''", "'", substr($value[2], 1, -1));
$cols[] = $value[1] . '=?';
} else {
$cols[] = $value[1] . '=' . $value[2];
}
}
$query = $update . implode(', ', $cols) . ' ' . $where;
unset($cols);
}
}
}
}
if (!function_exists('ibase_affected_rows') && (preg_match('/^UPDATE ([\\w_]++)\\s+SET [\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\\d-.]+)(?:,\\s*[\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\\d-.]+))*+\\s+(WHERE.*)?$/s', $query, $regs) || preg_match('/^DELETE FROM ([\\w_]++)\\s*(WHERE\\s*.*)?$/s', $query, $regs))) {
$affected_sql = 'SELECT COUNT(*) as num_rows_affected FROM ' . $regs[1];
if (!empty($regs[2])) {
$affected_sql .= ' ' . $regs[2];
}
if (!($temp_q_id = @ibase_query($this->db_connect_id, $affected_sql))) {
return false;
}
$temp_result = @ibase_fetch_assoc($temp_q_id);
@ibase_free_result($temp_q_id);
$this->affected_rows = $temp_result ? $temp_result['NUM_ROWS_AFFECTED'] : false;
}
if (sizeof($array)) {
$p_query = @ibase_prepare($this->db_connect_id, $query);
array_unshift($array, $p_query);
$this->query_result = call_user_func_array('ibase_execute', $array);
unset($array);
if ($this->query_result === false) {
$this->sql_error($query);
}
} else {
if (($this->query_result = @ibase_query($this->db_connect_id, $query)) === false) {
$this->sql_error($query);
}
}
if (defined('DEBUG_EXTRA')) {
$this->sql_report('stop', $query);
}
if (!$this->transaction) {
if (function_exists('ibase_commit_ret')) {
@ibase_commit_ret();
} else {
// way cooler than ibase_commit_ret :D
@ibase_query('COMMIT RETAIN;');
}
}
if ($cache_ttl && method_exists($cache, 'sql_save')) {
$this->open_queries[(int) $this->query_result] = $this->query_result;
$cache->sql_save($query, $this->query_result, $cache_ttl);
} else {
if (strpos($query, 'SELECT') === 0 && $this->query_result) {
//.........这里部分代码省略.........
示例5: prepare
/**
* Prepares a query for multiple execution with execute().
* @param $query query to be prepared
*
* @return DB statement resource
*/
function prepare($query)
{
$tokens = split('[\\&\\?]', $query);
$token = 0;
$types = array();
$qlen = strlen($query);
for ($i = 0; $i < $qlen; $i++) {
switch ($query[$i]) {
case '?':
$types[$token++] = DB_PARAM_SCALAR;
break;
case '&':
$types[$token++] = DB_PARAM_OPAQUE;
break;
}
}
$newquery = strtr($query, '&', '?');
$this->last_query = $query;
$newquery = $this->modifyQuery($newquery);
$stmt = ibase_prepare($this->connection, $newquery);
$this->prepare_types[(int) $stmt] = $types;
$this->manip_query[(int) $stmt] = DB::isManip($query);
return $stmt;
}
示例6: prepare
function prepare($query)
{
$this->last_query = $query;
$query = $this->modifyQuery($query);
$stmt = ibase_prepare($query);
$this->manip_query[(int) $stmt] = DB::isManip($query);
return $stmt;
}
示例7: Prepare
function Prepare($sql)
{
return $sql;
$stmt = ibase_prepare($sql);
if (!$stmt) {
return false;
}
return array($sql, $stmt);
}
示例8: __construct
/**
* InterbaseStatement constructor.
* @param resource $connection
* @param string $query
*/
public function __construct($connection, $query)
{
$this->connection = $connection;
$this->resource = ibase_prepare($connection, $query);
}
示例9: prepare
/**
* Prepares a query for multiple execution with execute().
*
* prepare() requires a generic query as string like <code>
* INSERT INTO numbers VALUES (?, ?, ?)
* </code>. The <kbd>?</kbd> characters are placeholders.
*
* Three types of placeholders can be used:
* + <kbd>?</kbd> a quoted scalar value, i.e. strings, integers
* + <kbd>!</kbd> value is inserted 'as is'
* + <kbd>&</kbd> requires a file name. The file's contents get
* inserted into the query (i.e. saving binary
* data in a db)
*
* Use backslashes to escape placeholder characters if you don't want
* them to be interpreted as placeholders. Example: <code>
* "UPDATE foo SET col=? WHERE col='over \& under'"
* </code>
*
* @param string $query query to be prepared
* @return mixed DB statement resource on success. DB_Error on failure.
*/
function prepare($query)
{
$tokens = preg_split('/((?<!\\\\)[&?!])/', $query, -1, PREG_SPLIT_DELIM_CAPTURE);
$token = 0;
$types = array();
$newquery = '';
foreach ($tokens as $key => $val) {
switch ($val) {
case '?':
$types[$token++] = DB_PARAM_SCALAR;
break;
case '&':
$types[$token++] = DB_PARAM_OPAQUE;
break;
case '!':
$types[$token++] = DB_PARAM_MISC;
break;
default:
$tokens[$key] = preg_replace('/\\\\([&?!])/', "\\1", $val);
$newquery .= $tokens[$key] . '?';
}
}
$newquery = substr($newquery, 0, -1);
$this->last_query = $query;
$newquery = $this->modifyQuery($newquery);
$stmt = @ibase_prepare($this->connection, $newquery);
if ($stmt === false) {
$stmt = $this->ibaseRaiseError();
} else {
$this->prepare_types[(int) $stmt] = $types;
$this->manip_query[(int) $stmt] = DB::isManip($query);
}
return $stmt;
}
示例10: prepare
/**
* Prepares a query for multiple execution with execute().
* With some database backends, this is emulated.
* prepare() requires a generic query as string like
* 'INSERT INTO numbers VALUES(?,?)' or
* 'INSERT INTO numbers VALUES(:foo,:bar)'.
* The ? and :name and are placeholders which can be set using
* bindParam() and the query can be sent off using the execute() method.
* The allowed format for :name can be set with the 'bindname_format' option.
*
* @param string $query the query to prepare
* @param mixed $types array that contains the types of the placeholders
* @param mixed $result_types array that contains the types of the columns in
* the result set or MDB2_PREPARE_RESULT, if set to
* MDB2_PREPARE_MANIP the query is handled as a manipulation query
* @param mixed $lobs key (field) value (parameter) pair for all lob placeholders
* @return mixed resource handle for the prepared query on success, a MDB2
* error on failure
* @access public
* @see bindParam, execute
*/
function prepare($query, $types = null, $result_types = null, $lobs = array())
{
if ($this->options['emulate_prepared']) {
return parent::prepare($query, $types, $result_types, $lobs);
}
$is_manip = $result_types === MDB2_PREPARE_MANIP;
$offset = $this->offset;
$limit = $this->limit;
$this->offset = $this->limit = 0;
$result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre'));
if ($result) {
if (MDB2::isError($result)) {
return $result;
}
$query = $result;
}
$placeholder_type_guess = $placeholder_type = null;
$question = '?';
$colon = ':';
$positions = array();
$position = 0;
while ($position < strlen($query)) {
$q_position = strpos($query, $question, $position);
$c_position = strpos($query, $colon, $position);
if ($q_position && $c_position) {
$p_position = min($q_position, $c_position);
} elseif ($q_position) {
$p_position = $q_position;
} elseif ($c_position) {
$p_position = $c_position;
} else {
break;
}
if (null === $placeholder_type) {
$placeholder_type_guess = $query[$p_position];
}
$new_pos = $this->_skipDelimitedStrings($query, $position, $p_position);
if (MDB2::isError($new_pos)) {
return $new_pos;
}
if ($new_pos != $position) {
$position = $new_pos;
continue;
//evaluate again starting from the new position
}
if ($query[$position] == $placeholder_type_guess) {
if (null === $placeholder_type) {
$placeholder_type = $query[$p_position];
$question = $colon = $placeholder_type;
}
if ($placeholder_type == ':') {
$regexp = '/^.{' . ($position + 1) . '}(' . $this->options['bindname_format'] . ').*$/s';
$parameter = preg_replace($regexp, '\\1', $query);
if ($parameter === '') {
$err = $this->raiseError(MDB2_ERROR_SYNTAX, null, null, 'named parameter name must match "bindname_format" option', __FUNCTION__);
return $err;
}
$positions[] = $parameter;
$query = substr_replace($query, '?', $position, strlen($parameter) + 1);
} else {
$positions[] = count($positions);
}
$position = $p_position + 1;
} else {
$position = $p_position;
}
}
$connection = $this->getConnection();
if (MDB2::isError($connection)) {
return $connection;
}
$statement = @ibase_prepare($connection, $query);
if (!$statement) {
$err = $this->raiseError(null, null, null, 'Could not create statement', __FUNCTION__);
return $err;
}
$class_name = 'MDB2_Statement_' . $this->phptype;
$obj = new $class_name($this, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset);
$this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj));
//.........这里部分代码省略.........
示例11: _prep_query
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*file:///var/www/html/ITMI_1.0/system/database/drivers/ibase/ibase_driver.php
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return @ibase_prepare($this->conn_id, $sql);
}
示例12: execute
/**
* This function processes an SQL statement that will NOT return data.
*
* @access public
* @override
* @param string $sql the SQL statement
* @throws Throwable_SQL_Exception indicates that the executed
* statement failed
*/
public function execute($sql)
{
if (!$this->is_connected()) {
throw new Throwable_SQL_Exception('Message: Failed to execute SQL statement. Reason: Unable to find connection.');
}
$statement = @ibase_prepare($this->resource, $sql);
$command = @ibase_execute($statement);
if ($command === FALSE) {
throw new Throwable_SQL_Exception('Message: Failed to execute SQL statement. Reason: :reason', array(':reason' => @ibase_errmsg()));
}
$this->sql = $sql;
}
示例13: exec
function exec($sql)
{
$this->error = "";
//Set the errors to none
$inputvalues = func_get_args();
if ($this->debug) {
$this->debugmsg("Executing SQL on " . $this->dbtype . " database....", "blue");
$this->debugmsg($sql, "purple");
}
//Validate the sql statement and make adjustments
$sql = $this->parsesql($sql);
switch ($this->dbtype) {
/* Firebird Functionality */
case "firebird":
$query = ibase_prepare($this->dbh, $sql);
$params = array();
$params[0] = $query;
//what if we have passed some parameters - firebird can do this
for ($i = 1; $i < func_num_args(); $i++) {
$params[$i] = func_get_arg($i);
}
if (sizeof($params) != 0) {
$anerror = call_user_func_array("ibase_execute", $params);
} else {
$anerror = ibase_execute($query);
}
break;
/* SQLite Functionality */
/* SQLite Functionality */
case "sqlite":
//Replace ? with parameters if given before executing. this is not a big problem
$sql = $this->replace_params($inputvalues, $sql);
$this->lastsql = $sql;
$anerror = "";
sqlite_exec($this->dbh, $sql, $anerror);
break;
/* MYSQL Functionality */
/* MYSQL Functionality */
case "mysql":
//Replace ? with parameters if given before executing. however this is not a big problem
$sql = $this->replace_params($inputvalues, $sql);
$this->lastsql = $sql;
$anerror = "";
mysql_query($sql);
$anerror = mysql_error($this->dbh);
break;
/* Oracle Functionality */
/* Oracle Functionality */
case "oracle":
//Replace ? with parameters if given before executing. this is not a big problem
$sql = $this->replace_params($inputvalues, $sql);
$this->lastsql = $sql;
$anerror = "";
$query = oci_parse($this->dbh, $sql);
$anerror = oci_execute($query);
break;
/* MSSQL Functionality */
/* MSSQL Functionality */
case "mssql":
//Replace ? with parameters if given before executing. this is not a big problem
$sql = $this->replace_params($inputvalues, $sql);
$this->lastsql = $sql;
mssql_query($sql);
$anerror = mssql_get_last_message();
break;
/* PGSQL Functionality */
/* PGSQL Functionality */
case "pgsql":
$params = array();
for ($i = 1; $i < sizeof($inputvalues); $i++) {
$tryme = $inputvalues[$i];
if (is_numeric($tryme)) {
$params[$count] = $inputvalues[$i];
} else {
$params[$count] = "'" . $inputvalues[$i] . "'";
}
$query = pg_prepare($this->dbh, "", $sql);
$anerror = pg_execute($this->dbh, "", $params);
break;
}
if ($this->debug) {
$this->debugmsg("SQL executed on " . $this->dbtype . " database.... returning {$anerror}", "green");
}
return $anerror;
}
}
示例14: PreQuery
function PreQuery($strSQL, $intTrans = 0)
{
if (!$this->intConn) {
$this->intConn = $this->Connect();
}
$this->strQuery = $strSQL;
if ($this->intDebug) {
echo "Preparing query...\t\t<br>";
}
if ($intTrans == 0) {
$this->intQuery = ibase_prepare($this->intConn, $this->strQuery);
} else {
$this->intQuery = $this->Transaction($this->intConn);
$this->intQuery = ibase_prepare($this->intTrans, $this->strQuery);
ibase_execute($this->intQuery);
}
return $this->intQuery;
}
示例15: prepare
/**
* Prepare
*
* @param string $sql
* @throws Exception\InvalidQueryException
* @throws Exception\RuntimeException
* @return Statement
*/
public function prepare($sql = null)
{
if ($this->isPrepared) {
throw new Exception\RuntimeException('This statement has already been prepared');
}
$sql = $sql ?: $this->sql;
$this->resource = ibase_prepare($sql);
if ($this->resource === false) {
throw new Exception\RuntimeException(ibase_errmsg(), ibase_errcode());
}
$this->isPrepared = true;
return $this;
}