Horde_Db_Adapter::update PHP Method

update() public method

Executes the update statement and returns the number of rows affected.
public update ( string $sql, mixed $arg1 = null, string $arg2 = null ) : integer
$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 integer Number of rows affected.
    public function update($sql, $arg1 = null, $arg2 = null);

Usage Example

Example #1
0
 /**
  * Set the location of the specified event _id
  *
  * @see Kronolith_Geo_Base#setLocation()
  * @throws Kronolith_Exception
  */
 public function setLocation($event_id, $point)
 {
     /* First make sure it doesn't already exist */
     $sql = 'SELECT COUNT(*) FROM kronolith_events_geo WHERE event_id = ?';
     try {
         $count = $this->_db->selectValue($sql, array($event_id));
     } catch (Horde_Db_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     /* Do we actually have data? If not, see if we are deleting an
      * existing entry. */
     if ((empty($point['lat']) || empty($point['lon'])) && $count) {
         // Delete the record.
         $this->deleteLocation($event_id);
         return;
     } elseif (empty($point['lat']) || empty($point['lon'])) {
         return;
     }
     if (empty($point['zoom'])) {
         $point['zoom'] = 0;
     }
     /* INSERT or UPDATE */
     $params = array($point['lat'], $point['lon'], $point['zoom'], $event_id);
     try {
         if ($count) {
             $sql = 'UPDATE kronolith_events_geo SET event_lat = ?, event_lon = ?, event_zoom = ? WHERE event_id = ?';
             $this->_db->update($sql, $params);
         } else {
             $sql = 'INSERT into kronolith_events_geo (event_lat, event_lon, event_zoom, event_id) VALUES(?, ?, ?, ?)';
             $this->_db->insert($sql, $params);
         }
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Exception($e);
     }
 }
All Usage Examples Of Horde_Db_Adapter::update