Source for file criteria.php
Documentation is available at criteria.php
// $Id: criteria.php 785 2006-11-06 06:11:17Z skalpa $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu) //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
// Modified by: Nathan Dial //
// Date: 20 March 2003 //
// Desc: added experimental LDAP filter generation code //
// also refactored to remove about 20 lines of redundant code. //
// ------------------------------------------------------------------------- //
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
* A criteria (grammar?) for a database query.
* Abstract base class should never be instantiated directly.
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
* Number of records to retrieve
* Render the criteria element
return ' GROUP BY '. $this->groupby;
* Collection of multiple {@link CriteriaElement}s
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
* The elements of the collection
* @var array Array of {@link CriteriaElement} objects
* @param string $condition
$this->add($ele, $condition);
* @param object &$criteriaElement
* @param string $condition
* @return object reference to this collection
function &add(&$criteriaElement, $condition= 'AND')
* Make the criteria into a query string
for ($i = 1; $i < $count; $i++ ) {
* Make the criteria into a SQL "WHERE" clause
$ret = ($ret != '') ? 'WHERE ' . $ret : $ret;
* Generate an LDAP filter from criteria
* @author Nathan Dial ndial@trillion21.com
for ($i = 1; $i < $count; $i++ ) {
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
* @param string $operator
function Criteria($column, $value= '', $operator= '=', $prefix = '', $function = '') {
* Make a sql condition string
$clause = sprintf($this->function, $clause);
if ( in_array( strtoupper( $this->operator ), array( 'IS NULL', 'IS NOT NULL' ) ) ) {
if ( '' === ($value = trim($this->value) ) ) {
if ( !in_array( strtoupper($this->operator), array('IN', 'NOT IN') ) ) {
if ( ( substr( $value, 0, 1 ) != '`' ) && ( substr( $value, -1 ) != '`' ) ) {
} elseif ( !preg_match( '/^[a-zA-Z0-9_\.\-`]*$/', $value ) ) {
* Generate an LDAP filter from criteria
* @author Nathan Dial ndial@trillion21.com, improved by Pierre-Eric MENUET pemen@sourceforge.net
$clause = "(!(" . $this->column . $operator . $this->value . "))";
$newvalue = str_replace(array('(',')'),'',
$tab = explode(',',$newvalue);
$clause .= '(' . $this->column . '=' . $uid
$clause = '(|' . $clause . ')';
* Make a SQL "WHERE" clause
return empty($cond) ? '' : "WHERE $cond";
|