db::affected PHP Method

affected() static public method

Returns the number of affected rows for the last query
static public affected ( ) : integer
return integer
    static function affected()
    {
        return self::$affected;
    }

Usage Example

Example #1
0
 /** 
  * Executes a MySQL query without result set.
  * This is used for queries like update, delete or insert
  *
  * @param  string  $sql The sql query
  * @return mixed
  */
 static function execute($sql)
 {
     $connection = self::connect();
     if (error($connection)) {
         return $connection;
     }
     // save the query
     self::$last_query = $sql;
     // execute the query
     $execute = @mysql_query($sql, $connection);
     self::$affected = @mysql_affected_rows();
     self::$trace[] = $sql;
     if (!$execute) {
         return self::error(l::get('db.errors.query_failed', 'The database query failed'));
     }
     $last_id = self::last_id();
     return $last_id === false ? self::$affected : self::last_id();
 }
All Usage Examples Of db::affected