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";
     }
 }
 /**
  * Executes a prepared statement.
  *
  * @param array $params OPTIONAL Values to bind to parameter placeholders.
  * @return bool
  * @throws ZendX_Db_Statement_Firebird_Exception
  */
 public function _execute(array $params = null)
 {
     if (!$this->_stmtPrepared) {
         return false;
     }
     // if no params were given as an argument to execute(),
     // then default to the _bindParam array
     if ($params === null) {
         $params = $this->_bindParam;
     }
     // send $params as input parameters to the statement
     if ($params) {
         array_unshift($params, $this->_stmtPrepared);
         $retval = @call_user_func_array('ibase_execute', $params);
     } else {
         // execute the statement
         $retval = @ibase_execute($this->_stmtPrepared);
     }
     $this->_stmtResult = $retval;
     if ($retval === false) {
         $last_error = ibase_errmsg();
         $this->_stmtRowCount = 0;
     }
     //Firebird php ibase extension, auto-commit is not after each call, but at
     //end of script. Disabled when transaction is active
     if (!$this->_adapter->getTransaction()) {
         ibase_commit_ret();
     }
     if ($retval === false) {
         /**
          * @see ZendX_Db_Statement_Firebird_Exception
          */
         require_once 'ZendX/Db/Statement/Firebird/Exception.php';
         throw new ZendX_Db_Statement_Firebird_Exception("Firebird statement execute error : " . $last_error);
     }
     // statements that have no result set do not return metadata
     if (is_resource($this->_stmtResult)) {
         // get the column names that will result
         $this->_keys = array();
         $coln = ibase_num_fields($this->_stmtResult);
         $this->_stmtColumnCount = $coln;
         for ($i = 0; $i < $coln; $i++) {
             $col_info = ibase_field_info($this->_stmtResult, $i);
             $this->_keys[] = $this->_adapter->foldCase($col_info['name']);
         }
         // set up a binding space for result variables
         $this->_values = array_fill(0, count($this->_keys), null);
         // set up references to the result binding space.
         // just passing $this->_values in the call_user_func_array()
         // below won't work, you need references.
         $refs = array();
         foreach ($this->_values as $i => &$f) {
             $refs[$i] =& $f;
         }
     }
     if ($trans = $this->_adapter->getTransaction()) {
         $this->_stmtRowCount = ibase_affected_rows($trans);
     } else {
         $this->_stmtRowCount = ibase_affected_rows($this->_adapter->getConnection());
     }
     return true;
 }
Пример #3
0
 function execute($stmt, $data = false)
 {
     $result = ibase_execute($stmt, $data);
     if (!$result) {
         return $this->raiseError();
     }
     if ($this->autocommit) {
         ibase_commit($this->connection);
     }
     return DB::isManip($this->manip_query[(int) $stmt]) ? DB_OK : new DB_result($this, $result);
 }
Пример #4
0
 /**
  * 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;
 }
Пример #5
0
 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;
     }
 }
Пример #6
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;
 }
Пример #7
0
 /**
  * Sends a request to execute a prepared statement with given parameters, and waits for the result.
  * @param array $parameters
  * @return resource A query result resource on success or <b>FALSE</b> on failure.
  */
 public function execute($parameters = [])
 {
     $this->queryResult = ibase_execute($this->resource, $parameters);
 }