Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules

Search

Donate to XOOPS!

Please select an amount to donate


Do you want your username revealed with your donation?
Yes - List me as a Generous Donor
No - List my donation as from an Anonymous Donor


Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

admin Arabic banner block Christmas comments cumulus DayDawn dhsoft e-Commerce E-Learning Git Google GUI hacks instant-zero jQuery module mygalleries news Nordic Olédrion oxygen PageRank PHP rmcommon security SEO simple-XOOPS Smarty sport tag Theme tutorial wiki WOX xoops XoopsEngine ZendFramework

New Users

Registering user

# 133963

hillsync

Welcome to XOOPS!
[Main Page]

Xoops Criteria Class

From XOOPS Web Application System

Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki mode

Printable version | Disclaimers | Privacy policy
Category: Development

The XOOPS API has a class called Criteria to aid in database searches. The class is defined as such:

Criteria Criteria (string $column, string $value = , string $operator = '=', mixed $prefix = , mixed $function = )

It's handy for returning a list of objects from the XoopsPersistableObjectHandler class.

Example:

$criteria = new Criteria('id', $object_id); 

$array = $objecthandler->getObjects($criteria, false, false);

This returns $array as an array of all elements following the criteria! If the third argument of the getObjects method is true, it returns objects instead, handy for bulk manipulation!

The Criteria class only handles a single 'WHERE' condition. If you need multiple conditions, use CriteriaCompo in combination with Criteria. Here is an example out of the mailusers file:

$criteria_object = new CriteriaCompo();

    foreach ($criteria as $c) {

        list ($field, $op, $value) = split(' ', $c); $criteria_object->add(new Criteria($field,$value,$op), 'AND');

    }

If you have just a few simple conditions, you can just use

$criteria_object = new CriteriaCompo();

$criteria_object->add(new Criteria($field1,$value1,$op1), 'AND');

$criteria_object->add(new Criteria($field2,$value2,$op2), 'AND');

Back to Main Page

Retrieved from "http://xoops.org/modules/mediawiki/index.php/Xoops_Criteria_Class"

This page has been accessed 3,885 times. This page was last modified 17:31, 12 April 2012. Content is available under XOOPS Web Application System.