[xoops-cvslog 2725] CVS update: xoops2jp/html/modules/base/kernel

Back to archive index

Minahito minah****@users*****
2006年 4月 11日 (火) 14:29:23 JST


Index: xoops2jp/html/modules/base/kernel/handler.php
diff -u xoops2jp/html/modules/base/kernel/handler.php:1.1.2.11 xoops2jp/html/modules/base/kernel/handler.php:1.1.2.12
--- xoops2jp/html/modules/base/kernel/handler.php:1.1.2.11	Tue Mar 28 22:30:15 2006
+++ xoops2jp/html/modules/base/kernel/handler.php	Tue Apr 11 14:29:23 2006
@@ -57,7 +57,7 @@
 		$sql = "SELECT * FROM " . $this->mTable;
 
 		if($criteria !== null && is_a($criteria, 'CriteriaElement')) {
-			$where = $criteria->render();
+			$where = $this->_makeCriteria4sql($criteria);
 			
 			if (trim($where)) {
 				$sql .= " WHERE ".$where;
@@ -119,7 +119,7 @@
 		$sql="SELECT COUNT(*) c FROM " . $this->mTable;
 
 		if($criteria !== null && is_a($criteria, 'CriteriaElement')) {
-			$where = $criteria->render();
+			$where = $this->_makeCriteria4sql($criteria);
 			
 			if ($where) {
 				$sql .= " WHERE " . $where;
@@ -221,7 +221,8 @@
 	 * @param $obj xoopsObject
 	 * @return Array
 	*/
-	function _makeVars4sql(&$obj) {
+	function _makeVars4sql(&$obj)
+	{
 		$ret = array();
 		foreach ($obj->gets() as $key => $value) {
 			switch ($obj->mVars[$key]['data_type']) {
@@ -237,6 +238,54 @@
 		
 		return $ret;
 	}
+	
+	function _makeCriteria4sql($criteria)
+	{
+		$dmmyObj =& $this->create();
+
+		return $this->_makeCriteriaElement4sql($criteria, $dmmyObj);
+	}
+
+	/**
+	 * @param $criteria CriteriaElement
+	 * @param $obj XoopsSimpleObject
+	 */	
+	function _makeCriteriaElement4sql($criteria, &$obj)
+	{
+		if (is_a($criteria, "CriteriaElement")) {
+			if ($criteria->hasChildElements()) {
+				$queryString = "";
+				$maxCount = $criteria->getCountChildElements();
+				for ($i = 0; $i < $maxCount ; $i++) {
+					$queryString .= " " . $this->_makeCriteria4sql($criteria->getChildElement($i));
+					if (($i + 1) != $maxCount) {
+						$queryString .= " " . $criteria->getCondition($i);
+					}
+				}
+				
+				return "(" . $queryString . ")";
+			}
+			else {
+				//
+				// Render
+				//
+				$name = $criteria->getName();
+				$value = null;
+				switch ($obj->mVars[$name]['data_type']) {
+					case XOBJ_DTYPE_STRING:
+					case XOBJ_DTYPE_TEXT:
+						$value = $this->db->quoteString($criteria->getValue());
+						break;
+						
+					default:
+						$value = $criteria->getValue();
+				}
+				
+				$string = $name . " " . $criteria->getOperator() . " " . $value;
+				return $string;
+			}
+		}
+	}
 
 	/**
 	 * @return bool


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