Helpers Database Functions

Functions

db_insert($table, $fields)

Run an insert query on the active databaseA collection of data related to an application..

  • Calling parameters
  • $table
    The databaseA collection of data related to an application. table on which to run the insert query.
    $fields
    An associative array of the values to insert. The keys are the fields, and the corresponding values are the values to insert.
  • Return
  • A databaseA collection of data related to an application. query result resource, or FALSE if the query was not executed correctly.

db_update($table, $fields, $where, $where_type='AND')

Run an update query on the active databaseA collection of data related to an application..

  • Calling parameters
  • $table
    The databaseA collection of data related to an application. table on which to run the insert query.
    $fields
    An associative array of the values to insert. The keys are the fields, and the corresponding values are the values to insert.
    $where
    The where rules for this update query.
    $where_type
    Whether to AND or OR the where rules together.
  • Return
  • A databaseA collection of data related to an application. query result resource, or FALSE if the query was not executed correctly.

db_delete($table, $where, $where_type='AND')

  • Calling parameters
  • $table
    The databaseA collection of data related to an application. table on which to run the insert query.
    $where
    The where rules for this update query.
    $where_type
    Whether to AND or OR the where rules together.
  • Return
  • A databaseA collection of data related to an application. query result resource, or FALSE if the query was not executed correctly.

db_where_clause($where, $where_type='AND', $where_keyword=TRUE)

Build the WHERE portion of an SQLStructured Query Language - a language for accessing a database. query, based on the specified values.

  • Calling parameters
  • $where
    Associative array of rules in the WHERE clause. If a key in the array is numeric, the value is taken as a literal rule. If it is non-numeric, then it is assumed to be a field name and the corresponding value is the value that it must hold.
    $where_type
    Whether to AND or OR the where rules together.
  • Return
  • An array containing the where clause with sprintf() markers, and an array of values to substitute for them.

As an example, this $where clause would be translated as follows:

$where = array('name'=>'foo', 'type'=>'page', 'created < 1147567877')

becomes:

WHERE (name='foo') AND ('type'='page') AND (created < 1147567877')

db_fetch_all_as_objects($query)

Returns an array with all objects from a query. This function does not do a rewrite_sqlStructured Query Language - a language for accessing a database. for you.

  • Calling parameters
  • $query
    A databaseA collection of data related to an application. query string.
  • Return
  • An array containing an object for each row returned by the query.

db_fetch_all_as_arrays($query)

Returns an array with all arrays from a query. This function does not do a rewrite_sqlStructured Query Language - a language for accessing a database. for you.

  • Calling parameters
  • $query
    A databaseA collection of data related to an application. query string.
  • Return
  • An array containing an array for each row returned by the query.

  • Calling parameters
  • Return

-->