From c6935514fbe8ead6aed2ee711e1ce106913a9f47 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Wed, 19 Dec 2007 14:23:19 +0000 Subject: Added where_in(), where_in_or(), where_not_in(), and where_not_in_or() to Active Record. --- user_guide/changelog.html | 2 +- user_guide/database/active_record.html | 41 ++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'user_guide') diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 8853969c4..55edb75d1 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -68,7 +68,7 @@ Change Log
  • Javascript Calendar plugin now uses the months and days from the calendar language file, instead of hard-coded values, internationalizing it.
  • Removed "rand()" as a listed option from orderby in the Active Record, as it was MySQL only.
  • Added 'random' as an order_by() option in Active Record.
  • -
  • Added where_in() to Active Record.
  • +
  • Added where_in(), where_in_or(), where_not_in(), and where_not_in_or() to Active Record.
  • Added titles to all user manual pages.
  • Added a check for NULL fields in the MySQL database backup utility.
  • Documented the timezones() function in the Date Helper.
  • diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 0146941ba..cf8ad469f 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -268,26 +268,33 @@ $this->db->or_where('id >', $id);

    $this->db->where_in();

    -

    This function is used to write WHERE clauses that contain the IN keyword.

    +

    Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate

    +

    + $names = array('Frank', 'Todd', 'James');
    + $this->db->where_in('username', $names);
    + // Produces: AND WHERE username IN ('Frank', 'Todd', 'James')

    + +

    $this->db->where_in_or();

    +

    Generates a WHERE field IN ('item', 'item') SQL query joined with OR if appropriate

    +

    + $names = array('Frank', 'Todd', 'James');
    + $this->db->where_in_or('username', $names);
    + // Produces: OR WHERE username IN ('Frank', 'Todd', 'James')

    + +

    $this->db->where_not_in();

    +

    Generates a WHERE field NOT IN ('item', 'item') SQL query joined with AND if appropriate

    +

    + $names = array('Frank', 'Todd', 'James');
    + $this->db->where_not_in('username', $names);
    + // Produces: AND WHERE username NOT IN ('Frank', 'Todd', 'James')

    +

    $this->db->where_not_in_or();

    +

    Generates a WHERE field NOT IN ('item', 'item') SQL query joined with OR if appropriate

    - $names = array('frank', 'Todd', 'James');
    + $names = array('Frank', 'Todd', 'James');
    $this->db->where_in('username', $names);
    - // Produces: AND WHERE username IN ('frank', 'Todd', 'James')

    -

    An optional third parameter can be used to specify if the WHERE statement should be separated with "OR" or "AND" in the event of multiple WHERE calls. The default is "AND". They are called with 'and', 'or'.

    -

    $names = array('frank', 'Todd', 'James');
    -
    - $this->db->where('usergroup', '5')
    -$this->db->where_in('username', $names);
    -// Produces: WHERE usergroup = '5' AND WHERE username IN ('frank', 'Todd', 'James')
    -
    -$this->db->where('usergroup', '5')
    -$this->db->where_in('username', $names, 'and');
    -// Produces: WHERE usergroup = '5' AND WHERE username IN ('frank', 'Todd', 'James')
    -
    -$this->db->where('usergroup', '5')
    -$this->db->where_in('username', $names, 'or');
    -// Produces: WHERE usergroup = '5' OR WHERE username IN ('frank', 'Todd', 'James')

    + // Produces: OR WHERE username NOT IN ('Frank', 'Todd', 'James')

    +

    $this->db->like();

    This function enables you to generate LIKE clauses, useful for doing searches.

    -- cgit v1.2.3-24-g4f1b