Database Class Methods

custom() method

Purpose:
To run a hand-written SQL query.

Format:

custom(query_string [, array(associative_array_of_values)])

Examples:

// Fetch a list of user records
$db ->custom('SELECT * FROM users WHERE user_id = :id OR status IN(:statuses)', [
  'id' => 5,
  'statuses' => ['Admin', 'Moderator']
])->fetchAll();

Implementation Explanation:
This method utilizes prepared queries when possible. The example above, when using the MySQL adaptor, will first get transformed into the following format:

SELECT * FROM users WHERE user_id = :id OR status IN(:statuses1, :statuses2)

That query will get sent to the MySQL server as a prepared statement.

From there the values you passed in as the 2nd argument will get bound to each of the variables.