User Login    
 + Register
  • Main navigation
Login
Username:

Password:


Lost Password?

Register now!
Documentation
Who's Online
108 user(s) are online (8 user(s) are browsing XoopsWiki)

Members: 4
Guests: 104

JamesN, gtr19911021, caek9, zorro87, more...
[Main Page]

Dev:XoopsCriteria

From XOOPS Project

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://www.xoops.org/modules/mediawiki/index.php/Dev:XoopsCriteria"

This page has been accessed 399 times. This page was last modified 17:19, 15 December 2007. Content is available under XOOPS Project.


Local Support Sites
Powered by
XOOPS Code hosted on SourceForge

Powered by PHP



Powered by MySQL

Powered by Smarty

OSI certified

All content on this site is subject to the Creative Commons License
Developers for Hire