execute() public method

Executes the SQL statement in the context of this connection.
Deprecation: Deprecated for external usage. Use select() instead.
public execute ( string $sql, mixed $arg1 = null, string $arg2 = null ) : mixed
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
return mixed
Ejemplo n.º 1
0
 /**
  * Sets a script running on the backend.
  *
  * @param array $script  The filter script information. Passed elements:
  *                       - 'name': (string) the script name.
  *                       - 'recipes': (array) the filter recipe objects.
  *                       - 'script': (string) the filter script.
  *
  * @throws Ingo_Exception
  */
 public function setScriptActive($script)
 {
     $this->_connect();
     try {
         foreach ($script['recipes'] as $recipe) {
             $this->_db->execute($recipe['object']->generate());
         }
     } catch (Horde_Db_Exception $e) {
         throw new Ingo_Exception($e);
     }
 }
Ejemplo n.º 2
0
 /**
  * Executes the SQL statement in the context of this connection.
  *
  * @param string $sql   SQL statement.
  * @param mixed $arg1   Either an array of bound parameters or a query
  *                      name.
  * @param string $arg2  If $arg1 contains bound parameters, the query
  *                      name.
  *
  * @return PDOStatement
  * @throws Horde_Db_Exception
  */
 public function execute($sql, $arg1 = null, $arg2 = null)
 {
     // Can't assume this will always be a read action, use _write.
     $result = $this->_write->execute($sql, $arg1, $arg2);
     $this->_lastQuery = $this->_write->getLastQuery();
     // Once doing writes, keep using the write backend even for reads
     // at least during the same request, to help against stale data.
     $this->_read = $this->_write;
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Implementation of the rewind() method for iterator.
  */
 public function rewind()
 {
     if ($this->_result) {
         unset($this->_result);
     }
     $this->_current = null;
     $this->_index = null;
     $this->_eof = true;
     $this->_result = $this->_adapter->execute($this->_sql, $this->_arg1, $this->_arg2);
     $this->next();
 }
Ejemplo n.º 4
0
 public function getMany($num = 50)
 {
     $tasks = array();
     $values = array();
     $query = 'SELECT * FROM horde_queue_tasks where task_queue = ? ORDER BY task_id LIMIT ?';
     $values[] = $this->_queue;
     $values[] = $num;
     try {
         $rows = $this->_db->selectAll($query, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Queue_Exception($e);
     }
     $query = 'DELETE FROM horde_queue_tasks WHERE task_id = ?';
     foreach ($rows as $row) {
         $tasks[] = unserialize($row['task_fields']);
         // TODO: Evaluate if a single call for all IDs is faster for various scenarios
         try {
             $rows = $this->_db->execute($query, array($row['task_id']));
         } catch (Horde_Db_Exception $e) {
             throw new Horde_Queue_Exception($e);
         }
     }
     return $tasks;
 }
Ejemplo n.º 5
0
Archivo: Sql.php Proyecto: horde/horde
 /**
  * Create table for submiting data.
  *
  * @return boolean  True on success.
  * @throws Ulaform_Exception
  */
 protected function _createDataTable($form_params, $fields)
 {
     /* Generate SQL query. */
     $columns = array();
     foreach ($fields as $field) {
         switch ($field['field_type']) {
             case 'file':
             case 'image':
                 // TODO: Use Horde_SQL
                 switch (Horde_String::lower($this->_db->adapterName())) {
                     case 'pgsql':
                         $columns[] = $field['field_name'] . ' TEXT';
                         break;
                     case 'mysql':
                     case 'mysqli':
                         $columns[] = $field['field_name'] . ' MEDIUMBLOB';
                         break;
                     default:
                         $columns[] = $field['field_name'] . ' BLOB';
                         break;
                 }
                 break;
             case 'address':
             case 'countedtext':
             case 'description':
             case 'html':
             case 'longtext':
             case 'set':
                 $columns[] = $field['field_name'] . ' TEXT';
                 break;
             default:
                 $columns[] = $field['field_name'] . ' VARCHAR(255)';
                 break;
         }
     }
     $sql = sprintf('CREATE TABLE %s (%s)', $form_params['table'], implode(', ', $columns));
     /* Create table. */
     try {
         $this->_db->execute($sql);
     } catch (Horde_Db_Exception $e) {
         throw new Ulaform_Exception($e);
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Saves a forum, either creating one if no forum ID is given or updating
  * an existing one.
  *
  * @param array $info  The forum information to save consisting of:
  *                       forum_id
  *                       forum_author
  *                       forum_parent_id
  *                       forum_name
  *                       forum_moderated
  *                       forum_description
  *                       forum_attachments
  *
  * @return integer  The forum ID on success.
  * @throws Agora_Exception
  */
 public function saveForum($info)
 {
     if (empty($info['forum_id'])) {
         if (empty($info['author'])) {
             $info['author'] = $GLOBALS['registry']->getAuth();
         }
         $info['forum_id'] = $this->newForum($info['forum_name'], $info['author']);
     }
     $sql = 'UPDATE ' . $this->_forums_table . ' SET forum_name = ?, forum_parent_id = ?, ' . 'forum_description = ?, forum_moderated = ?, ' . 'forum_attachments = ?, forum_distribution_address = ? ' . 'WHERE forum_id = ?';
     $values = array($this->convertToDriver($info['forum_name']), (int) $info['forum_parent_id'], $this->convertToDriver($info['forum_description']), (int) $info['forum_moderated'], isset($info['forum_attachments']) ? (int) $info['forum_attachments'] : abs($GLOBALS['conf']['forums']['enable_attachments']), isset($info['forum_distribution_address']) ? $info['forum_distribution_address'] : '', $info['forum_id']);
     try {
         $this->_db->execute($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Agora_Exception($e->getMessage());
     }
     $this->_updateCacheState(0);
     $this->_cache->expire('agora_forum_' . $info['forum_id'], $GLOBALS['conf']['cache']['default_lifetime']);
     return $info['forum_id'];
 }