[xoops-cvslog 14] CVS update: xoops2jp/html/class

Back to archive index

onokazu onoka****@users*****
2005年 5月 28日 (土) 08:03:33 JST


Index: xoops2jp/html/class/criteria.php
diff -u xoops2jp/html/class/criteria.php:1.2 xoops2jp/html/class/criteria.php:1.2.6.1
--- xoops2jp/html/class/criteria.php:1.2	Fri Mar 18 21:51:55 2005
+++ xoops2jp/html/class/criteria.php	Sat May 28 08:03:33 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: criteria.php,v 1.2 2005/03/18 12:51:55 onokazu Exp $
+// $Id: criteria.php,v 1.2.6.1 2005/05/27 23:03:33 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -35,55 +35,55 @@
 // ------------------------------------------------------------------------- //
 
 /**
- * 
- * 
+ *
+ *
  * @package     kernel
  * @subpackage  database
- * 
- * @author	    Kazumi Ono	<onoka****@xoops*****>
- * @copyright	copyright (c) 2000-2003 XOOPS.org
+ *
+ * @author      Kazumi Ono  <onoka****@xoops*****>
+ * @copyright   copyright (c) 2000-2003 XOOPS.org
  */
 
 /**
  * A criteria (grammar?) for a database query.
- * 
+ *
  * Abstract base class should never be instantiated directly.
- * 
+ *
  * @abstract
- * 
+ *
  * @package     kernel
  * @subpackage  database
- * 
- * @author	    Kazumi Ono	<onoka****@xoops*****>
- * @copyright	copyright (c) 2000-2003 XOOPS.org
+ *
+ * @author      Kazumi Ono  <onoka****@xoops*****>
+ * @copyright   copyright (c) 2000-2003 XOOPS.org
  */
 class CriteriaElement
 {
-	/**
-	 * Sort order
-     * @var	string
-	 */
-	var $order = 'ASC';
-    
     /**
-     * @var	string
+     * Sort order
+     * @var string
+     */
+    var $order = 'ASC';
+
+    /**
+     * @var string
      */
     var $sort = '';
 
     /**
      * Number of records to retrieve
-     * @var	int
+     * @var int
      */
     var $limit = 0;
-    
+
     /**
      * Offset of first record
-     * @var	int
+     * @var int
      */
     var $start = 0;
-    
+
     /**
-     * @var	string
+     * @var string
      */
     var $groupby = '';
 
@@ -106,8 +106,8 @@
     /**#@+
      * Accessor
      */
-    /** 
-     * @param	string  $sort
+    /**
+     * @param   string  $sort
      */
     function setSort($sort)
     {
@@ -115,7 +115,7 @@
     }
 
     /**
-     * @return	string
+     * @return  string
      */
     function getSort()
     {
@@ -123,7 +123,7 @@
     }
 
     /**
-     * @param	string  $order
+     * @param   string  $order
      */
     function setOrder($order)
     {
@@ -133,7 +133,7 @@
     }
 
     /**
-     * @return	string
+     * @return  string
      */
     function getOrder()
     {
@@ -141,7 +141,7 @@
     }
 
     /**
-     * @param	int $limit
+     * @param   int $limit
      */
     function setLimit($limit=0)
     {
@@ -149,7 +149,7 @@
     }
 
     /**
-     * @return	int
+     * @return  int
      */
     function getLimit()
     {
@@ -157,7 +157,7 @@
     }
 
     /**
-     * @param	int $start
+     * @param   int $start
      */
     function setStart($start=0)
     {
@@ -165,7 +165,7 @@
     }
 
     /**
-     * @return	int
+     * @return  int
      */
     function getStart()
     {
@@ -173,14 +173,14 @@
     }
 
     /**
-     * @param	string  $group
+     * @param   string  $group
      */
     function setGroupby($group){
         $this->groupby = $group;
     }
 
     /**
-     * @return	string
+     * @return  string
      */
     function getGroupby(){
         return ' GROUP BY '.$this->groupby;
@@ -189,32 +189,32 @@
 }
 
 /**
- * Collection of multiple {@link CriteriaElement}s 
- * 
+ * Collection of multiple {@link CriteriaElement}s
+ *
  * @package     kernel
  * @subpackage  database
- * 
- * @author	    Kazumi Ono	<onoka****@xoops*****>
- * @copyright	copyright (c) 2000-2003 XOOPS.org
+ *
+ * @author      Kazumi Ono  <onoka****@xoops*****>
+ * @copyright   copyright (c) 2000-2003 XOOPS.org
  */
 class CriteriaCompo extends CriteriaElement
 {
 
     /**
      * The elements of the collection
-     * @var	array   Array of {@link CriteriaElement} objects
+     * @var array   Array of {@link CriteriaElement} objects
      */
     var $criteriaElements = array();
 
     /**
      * Conditions
-     * @var	array
+     * @var array
      */
     var $conditions = array();
 
     /**
      * Constructor
-     * 
+     *
      * @param   object  $ele
      * @param   string  $condition
      **/
@@ -227,10 +227,10 @@
 
     /**
      * Add an element
-     * 
+     *
      * @param   object  &$criteriaElement
      * @param   string  $condition
-     * 
+     *
      * @return  object  reference to this collection
      **/
     function &add(&$criteriaElement, $condition='AND')
@@ -242,8 +242,8 @@
 
     /**
      * Make the criteria into a query string
-     * 
-     * @return	string
+     *
+     * @return  string
      */
     function render()
     {
@@ -261,8 +261,8 @@
 
     /**
      * Make the criteria into a SQL "WHERE" clause
-     * 
-     * @return	string
+     *
+     * @return  string
      */
     function renderWhere()
     {
@@ -299,35 +299,35 @@
 
 /**
  * A single criteria
- * 
+ *
  * @package     kernel
  * @subpackage  database
- * 
- * @author	    Kazumi Ono	<onoka****@xoops*****>
- * @copyright	copyright (c) 2000-2003 XOOPS.org
+ *
+ * @author      Kazumi Ono  <onoka****@xoops*****>
+ * @copyright   copyright (c) 2000-2003 XOOPS.org
  */
 class Criteria extends CriteriaElement
 {
 
     /**
-     * @var	string
+     * @var string
      */
-	var $prefix;
-	var $function;
+    var $prefix;
+    var $function;
     var $column;
     var $operator;
     var $value;
 
     /**
      * Constructor
-     * 
+     *
      * @param   string  $column
      * @param   string  $value
      * @param   string  $operator
      **/
     function Criteria($column, $value='', $operator='=', $prefix = '', $function = '') {
-		$this->prefix = $prefix;
-		$this->function = $function;
+        $this->prefix = $prefix;
+        $this->function = $function;
         $this->column = $column;
         $this->value = $value;
         $this->operator = $operator;
@@ -335,24 +335,24 @@
 
     /**
      * Make a sql condition string
-     * 
+     *
      * @return  string
      **/
     function render() {
-		if ( is_numeric($this->value) || strtoupper($this->operator) == 'IN') {
-			$value = $this->value;
-		} else {
-			if ( '' === ($value = trim($this->value)) ) {
-				return '';
-			}
-			if ( (substr($value, 0, 1) != '`') && (substr($value, -1) != '`') ) {
-				$value = "'$value'";
-			}
-		}
-		$clause = (!empty($this->prefix) ? "{$this->prefix}." : "") . $this->column;
-		if ( !empty($this->function) ) {
-			$clause = sprintf($this->function, $clause);
-		}
+        if (is_numeric($this->value) || in_array(strtoupper($this->operator), array('IN', 'NOT IN'))) {
+            $value = $this->value;
+        } else {
+            if ( '' === ($value = trim($this->value)) ) {
+                return '';
+            }
+            if ( (substr($value, 0, 1) != '`') && (substr($value, -1) != '`') ) {
+                $value = "'$value'";
+            }
+        }
+        $clause = (!empty($this->prefix) ? "{$this->prefix}." : "") . $this->column;
+        if ( !empty($this->function) ) {
+            $clause = sprintf($this->function, $clause);
+        }
         $clause .= " {$this->operator} $value";
         return $clause;
     }
@@ -370,11 +370,11 @@
 
     /**
      * Make a SQL "WHERE" clause
-     * 
-     * @return	string
+     *
+     * @return  string
      */
     function renderWhere() {
-		$cond = $this->render();
+        $cond = $this->render();
         return empty($cond) ? '' : "WHERE $cond";
     }
 }


xoops-cvslog メーリングリストの案内
Back to archive index