Header Small Ahoy!

The 'Get Where Custom' Method

The 'Get Where Custom' method is for fetching rows of data from a database table. It accepts the following parameters:

The starting point for a database results set is always assumed to have an offset of 0.

What Gets Returned?


If matching records are found then a PHP array will be returned where each item on the array represents a row from a database table. Each row, within the array, will be a PHP object.


If the query fails to find any matching records then an empty array will be returned.

Use PHP's inbuilt var_dump() method whenever you need to clarify the variable types from a given results set.

Example 1

The syntax below shows the simplest Get Where Custom example possible. In this example, we are passing in a column name of 'first_name' and a value of 'Bruce'.

$rows = $this->model->get_where_custom("first_name", "Bruce");

The code above will produce the following SQL query:

SELECT * from tablename WHERE first_name = 'Bruce' order by id

Below is an example of a Members.php controller file that contains a test() method. Here we're invoking a basic 'Get' command and then immediately displaying the results using Trongate's json() method:

class Members extends Trongate {

  function test() {
    $rows = $this->model->get_where_custom("first_name", "Bruce");

Below shows an example of the kind of output that we can expect to see from the above method, when Debug Mode is switched on:


Example 2

Below is a more advanced example:

$rows = $this->model->get_where_custom("trongate_user_id", 88, ">", "id desc", "members", "99", 1);

The code above would produce the following SQL query:

SELECT * FROM members where trongate_user_id > 88 order by id desc LIMIT 1, 99