コード例 #1
0
 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
0
ファイル: Firebird.php プロジェクト: dalinhuang/popo
 /**
  * @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
0
ファイル: class.db.php プロジェクト: roychoo/jstree
 public function prepare($sql)
 {
     if (!$this->is_connected()) {
         $this->connect();
     }
     return ibase_prepare($this->lnk, $sql);
 }
コード例 #4
0
ファイル: firebird.php プロジェクト: BACKUPLIB/mwenhanced
 /**
  * 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) {
                     $this->open_queries[(int) $this->query_result] = $this->query_result;
                 }
             }
         } else {
             if (defined('DEBUG_EXTRA')) {
                 $this->sql_report('fromcache', $query);
             }
         }
     } else {
         return false;
     }
     return $this->query_result;
 }
コード例 #5
0
ファイル: ibase.php プロジェクト: amjadtbssm/website
 /**
  * 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
0
ファイル: ibase.php プロジェクト: joeymetal/v1
 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
0
 function Prepare($sql)
 {
     return $sql;
     $stmt = ibase_prepare($sql);
     if (!$stmt) {
         return false;
     }
     return array($sql, $stmt);
 }
コード例 #8
0
 /**
  * InterbaseStatement constructor.
  * @param resource $connection
  * @param string   $query
  */
 public function __construct($connection, $query)
 {
     $this->connection = $connection;
     $this->resource = ibase_prepare($connection, $query);
 }
コード例 #9
0
ファイル: ibase.php プロジェクト: ryo88c/BEAR.Saturday
 /**
  * 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
0
ファイル: ibase.php プロジェクト: Dulciane/jaws
 /**
  * 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));
     return $obj;
 }
コード例 #11
0
 /**
  * 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
0
ファイル: Standard.php プロジェクト: ruslankus/invoice-crm
 /**
  * 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
0
ファイル: cdeclass.php プロジェクト: mortalerror/ultimatesims
 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
0
 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
0
ファイル: Statement.php プロジェクト: srayner/zend-db
 /**
  * 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;
 }
コード例 #16
0
ファイル: Ibase.php プロジェクト: saqar/tc_aowow
 function _performQuery($queryMain)
 {
     $this->_lastQuery = $queryMain;
     $this->_expandPlaceholders($queryMain, $this->DbSimple_Ibase_USE_NATIVE_PHOLDERS);
     $hash = $queryMain[0];
     if (!isset($this->prepareCache[$hash])) {
         $this->prepareCache[$hash] = @ibase_prepare(is_resource($this->trans) ? $this->trans : $this->link, $queryMain[0]);
     } else {
         // Prepare cache hit!
     }
     $prepared = $this->prepareCache[$hash];
     if (!$prepared) {
         return $this->_setDbError($queryMain[0]);
     }
     $queryMain[0] = $prepared;
     $result = @call_user_func_array('ibase_execute', $queryMain);
     // ATTENTION!!!
     // WE MUST save prepared ID (stored in $prepared variable) somewhere
     // before returning $result because of ibase destructor. Now it is done
     // by $this->prepareCache. When variable $prepared goes out of scope, it
     // is destroyed, and memory for result also freed by PHP. Totally we
     // got "Invalud statement handle" error message.
     if ($result === false) {
         return $this->_setDbError($queryMain[0]);
     }
     if (!is_resource($result)) {
         // Non-SELECT queries return number of affected rows, SELECT - resource.
         return @ibase_affected_rows(is_resource($this->trans) ? $this->trans : $this->link);
     }
     return $result;
 }
コード例 #17
0
 /**
  * @brief : 쿼리문의 실행 및 결과의 fetch 처리
  *
  * query : query문 실행하고 result return\n
  * fetch : reutrn 된 값이 없으면 NULL\n
  *         rows이면 array object\n
  *         row이면 object\n
  *         return\n
  **/
 function _query($query, $params = null)
 {
     if (!$this->isConnected()) {
         return;
     }
     if (count($params) == 0) {
         // 쿼리 시작을 알림
         $this->actStart($query);
         // 쿼리 문 실행
         $result = ibase_query($this->fd, $query);
     } else {
         // 쿼리 시작을 알림
         $log = $query . "\n\t\t\t";
         $log .= implode(",", $params);
         $this->actStart($log);
         // 쿼리 문 실행 (blob type 입력하기 위한 방법)
         $query = ibase_prepare($this->fd, $query);
         $fnarr = array_merge(array($query), $params);
         $result = call_user_func_array("ibase_execute", $fnarr);
     }
     // 오류 체크
     if (ibase_errmsg()) {
         $this->setError(ibase_errcode(), ibase_errmsg());
     }
     // 쿼리 실행 종료를 알림
     $this->actFinish();
     // 결과 리턴
     return $result;
 }
コード例 #18
0
ファイル: adodb-ibase.inc.php プロジェクト: kractos26/orfeo
 function Prepare($sql)
 {
     $stmt = ibase_prepare($this->_connectionID, $sql);
     if (!$stmt) {
         return false;
     }
     return array($sql, $stmt);
 }
コード例 #19
0
ファイル: Ibase.php プロジェクト: vakata/database
 public function prepare($sql)
 {
     $this->connect();
     return \ibase_prepare($this->transaction !== null ? $this->transaction : $this->lnk, $sql);
 }