src/DB/PDO/TableReader.php
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useIndices = TRUE, $allowFunctions = FALSE ){
		$columnConditions = array();
		foreach( $this->columns as $column ){														//  iterate all columns
			if( isset( $conditions[$column] ) ){														//  if condition given
				$columnConditions[$column] = $conditions[$column];									//  note condition pair
				unset( $conditions[$column] );
			}
		}
		$functionConditions = array();
		foreach( $conditions as $key => $value )													//  iterate remaining conditions
			if( preg_match( "/^[a-z]+\(.+\)$/i", $key ) )											//  column key is a aggregate function
				$functionConditions[$key]	= $value;

		if( $usePrimary && $this->isFocused( $this->primaryKey ) ){									//  if using primary key & is focused primary
			if( !array_key_exists( $this->primaryKey, $columnConditions ) )							//  if primary key is not already in conditions
				$columnConditions = $this->getFocus();												//  note primary key pair
		}
		if( $useIndices && count( $this->focusedIndices ) ){											//  if using indices
			foreach( $this->focusedIndices as $index => $value )									//  iterate focused indices
				if( $index != $this->primaryKey )													//  skip primary key
					if( !array_key_exists( $index, $columnConditions ) )							//  if index column is not already in conditions
						$columnConditions[$index] = $value;											//  note index pair
		}

		$conditions = array();																		//  restart with fresh conditions array

		foreach( $columnConditions as $column => $value ){											//  iterate noted column conditions
			if( is_array( $value ) ){
				foreach( $value as $nr => $part )
					$value[$nr]	= $this->realizeConditionQueryPart( $column, $part );
				$part	= '('.implode( ' OR ', $value ).')';
			}
			else
				$part	= $this->realizeConditionQueryPart( $column, $value );
			$conditions[]	= $part;

		}

		/*  --  THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE  --  */
		if( $allowFunctions )																		//  function are allowed
			foreach( $functionConditions as $function => $value ){									//  iterate noted functions
				$conditions[]	= $this->realizeConditionQueryPart( $function, $value, FALSE );		//  extend conditions
			}

		return implode( ' AND ', $conditions );														//  return AND combined conditions
	}
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useIndices = TRUE, $allowFunctions = FALSE ){
		$columnConditions = array();
		foreach( $this->columns as $column ){														//  iterate all columns
			if( isset( $conditions[$column] ) ){														//  if condition given
				$columnConditions[$column] = $conditions[$column];									//  note condition pair
				unset( $conditions[$column] );
			}
		}
		$functionConditions = array();
		foreach( $conditions as $key => $value )													//  iterate remaining conditions
			if( preg_match( "/^[a-z]+\(.+\)$/i", $key ) )											//  column key is a aggregate function
				$functionConditions[$key]	= $value;

		if( $usePrimary && $this->isFocused( $this->primaryKey ) ){									//  if using primary key & is focused primary
			if( !array_key_exists( $this->primaryKey, $columnConditions ) )							//  if primary key is not already in conditions
				$columnConditions = $this->getFocus();												//  note primary key pair
		}
		if( $useIndices && count( $this->focusedIndices ) ){											//  if using indices
			foreach( $this->focusedIndices as $index => $value )									//  iterate focused indices
				if( $index != $this->primaryKey )													//  skip primary key
					if( !array_key_exists( $index, $columnConditions ) )							//  if index column is not already in conditions
						$columnConditions[$index] = $value;											//  note index pair
		}

		$conditions = array();																		//  restart with fresh conditions array

		foreach( $columnConditions as $column => $value ){											//  iterate noted column conditions
			if( is_array( $value ) ){
				foreach( $value as $nr => $part )
					$value[$nr]	= $this->realizeConditionQueryPart( $column, $part );
				$part	= '('.implode( ' OR ', $value ).')';
			}
			else
				$part	= $this->realizeConditionQueryPart( $column, $value );
			$conditions[]	= $part;

		}

		/*  --  THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE  --  */
		if( $allowFunctions )																		//  function are allowed
			foreach( $functionConditions as $function => $value ){									//  iterate noted functions
				$conditions[]	= $this->realizeConditionQueryPart( $function, $value, FALSE );		//  extend conditions
			}

		return implode( ' AND ', $conditions );														//  return AND combined conditions
	}
protected function getConditionQuery ( $ conditions , $ usePrimary = TRUE , $ useIndices = TRUE , $ allowFunctions = FALSE ) { $ columnConditions = array ( ) ; foreach ( $ this -> columns as $ column ) { //  iterate all columns if ( isset ( $ conditions [ $ column ] ) ) { //  if condition given $ columnConditions [ $ column ] = $ conditions [ $ column ] ; //  note condition pair unset ( $ conditions [ $ column ] ) ; } } $ functionConditions = array ( ) ; foreach ( $ conditions as $ key => $ value ) //  iterate remaining conditions if ( preg_match ( "/^[a-z]+\(.+\)$/i" , $ key ) ) //  column key is a aggregate function $ functionConditions [ $ key ] = $ value ; if ( $ usePrimary && $ this -> isFocused ( $ this -> primaryKey ) ) { //  if using primary key & is focused primary if ( ! array_key_exists ( $ this -> primaryKey , $ columnConditions ) ) //  if primary key is not already in conditions $ columnConditions = $ this -> getFocus ( ) ; //  note primary key pair } if ( $ useIndices && count ( $ this -> focusedIndices ) ) { //  if using indices foreach ( $ this -> focusedIndices as $ index => $ value ) //  iterate focused indices if ( $ index != $ this -> primaryKey ) //  skip primary key if ( ! array_key_exists ( $ index , $ columnConditions ) ) //  if index column is not already in conditions $ columnConditions [ $ index ] = $ value ; //  note index pair } $ conditions = array ( ) ; //  restart with fresh conditions array foreach ( $ columnConditions as $ column => $ value ) { //  iterate noted column conditions if ( is_array ( $ value ) ) { foreach ( $ value as $ nr => $ part ) $ value [ $ nr ] = $ this -> realizeConditionQueryPart ( $ column , $ part ) ; $ part = '(' . implode ( ' OR ' , $ value ) . ')' ; } else $ part = $ this -> realizeConditionQueryPart ( $ column , $ value ) ; $ conditions [ ] = $ part ; } /*  --  THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE  --  */ if ( $ allowFunctions ) //  function are allowed foreach ( $ functionConditions as $ function => $ value ) { //  iterate noted functions $ conditions [ ] = $ this -> realizeConditionQueryPart ( $ function , $ value , FALSE ) ; //  extend conditions } return implode ( ' AND ' , $ conditions ) ; //  return AND combined conditions }
Builds and returns WHERE statement component.
@access		protected
@param		array		$conditions		Array of conditions
@param		bool		$usePrimary		Flag: use focused primary key
@param		bool		$useIndices		Flag: use focused indices
@return		string
Builds and returns WHERE statement component .