src/DB/TableReader.php
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useForeign = TRUE )
	{
		$new = array();
		foreach( $this->fields as $field )									//  iterate all Fields
			if( isset( $conditions[$field] ) )								//  if Condition given
				$new[$field] = $conditions[$field];							//  note Condition Pair
		if( $useForeign && count( $this->foreignFocuses ) )					//  if using Foreign Keys
			foreach( $this->foreignFocuses as $key => $value )				//  iterate focused Foreign Keys & is focused Foreign
				$new[$key] = $value; 										//  note foreign Key Pair

		if( $usePrimary && $this->isFocused() == 'primary' )				//  if using foreign Keys & is focused primary
			$new[$this->focusKey] = $this->focus;							//  note primary Key Pair

		$pattern	= '/^(<=|>=|<|>|!=)(.+)/';
		$conditions = array();
		foreach( $new as $key => $value )									//  iterate all noted Pairs
		{
			$operation	= ' = ';
			if( preg_match( '/%/', $value ) )
				$operation	= ' LIKE ';
			else if( preg_match( $pattern, $value ) )
			{
				$matches	= array();
				preg_match_all( $pattern, $value, $matches );
				$operation	= ' '.$matches[1][0].' ';
				$value		= $matches[2][0];
			}
			if( !ini_get( 'magic_quotes_gpc' ) )
			{
				$key	= addslashes( $key );
				$value	= addslashes( $value );
			}
			$conditions[] = '`'.$key.'`'.$operation."'".$value."'";			//  create SQL WHERE Condition
		}
		$conditions = implode( ' AND ', $conditions );						//  combine Conditions with AND
		return $conditions;
	}
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useForeign = TRUE )
	{
		$new = array();
		foreach( $this->fields as $field )									//  iterate all Fields
			if( isset( $conditions[$field] ) )								//  if Condition given
				$new[$field] = $conditions[$field];							//  note Condition Pair
		if( $useForeign && count( $this->foreignFocuses ) )					//  if using Foreign Keys
			foreach( $this->foreignFocuses as $key => $value )				//  iterate focused Foreign Keys & is focused Foreign
				$new[$key] = $value; 										//  note foreign Key Pair

		if( $usePrimary && $this->isFocused() == 'primary' )				//  if using foreign Keys & is focused primary
			$new[$this->focusKey] = $this->focus;							//  note primary Key Pair

		$pattern	= '/^(<=|>=|<|>|!=)(.+)/';
		$conditions = array();
		foreach( $new as $key => $value )									//  iterate all noted Pairs
		{
			$operation	= ' = ';
			if( preg_match( '/%/', $value ) )
				$operation	= ' LIKE ';
			else if( preg_match( $pattern, $value ) )
			{
				$matches	= array();
				preg_match_all( $pattern, $value, $matches );
				$operation	= ' '.$matches[1][0].' ';
				$value		= $matches[2][0];
			}
			if( !ini_get( 'magic_quotes_gpc' ) )
			{
				$key	= addslashes( $key );
				$value	= addslashes( $value );
			}
			$conditions[] = '`'.$key.'`'.$operation."'".$value."'";			//  create SQL WHERE Condition
		}
		$conditions = implode( ' AND ', $conditions );						//  combine Conditions with AND
		return $conditions;
	}
protected function getConditionQuery ( $ conditions , $ usePrimary = TRUE , $ useForeign = TRUE ) { $ new = array ( ) ; foreach ( $ this -> fields as $ field ) //  iterate all Fields
 if ( isset ( $ conditions [ $ field ] ) ) //  if Condition given
 $ new [ $ field ] = $ conditions [ $ field ] ; //  note Condition Pair
 if ( $ useForeign && count ( $ this -> foreignFocuses ) ) //  if using Foreign Keys
 foreach ( $ this -> foreignFocuses as $ key => $ value ) //  iterate focused Foreign Keys & is focused Foreign
 $ new [ $ key ] = $ value ; //  note foreign Key Pair
 if ( $ usePrimary && $ this -> isFocused ( ) == 'primary' ) //  if using foreign Keys & is focused primary
 $ new [ $ this -> focusKey ] = $ this -> focus ; //  note primary Key Pair
 $ pattern = '/^(<=|>=|<|>|!=)(.+)/' ; $ conditions = array ( ) ; foreach ( $ new as $ key => $ value ) //  iterate all noted Pairs
 { $ operation = ' = ' ; if ( preg_match ( '/%/' , $ value ) ) $ operation = ' LIKE ' ; else if ( preg_match ( $ pattern , $ value ) ) { $ matches = array ( ) ; preg_match_all ( $ pattern , $ value , $ matches ) ; $ operation = ' ' . $ matches [ 1 ] [ 0 ] . ' ' ; $ value = $ matches [ 2 ] [ 0 ] ; } if ( ! ini_get ( 'magic_quotes_gpc' ) ) { $ key = addslashes ( $ key ) ; $ value = addslashes ( $ value ) ; } $ conditions [ ] = '`' . $ key . '`' . $ operation . "'" . $ value . "'" ; //  create SQL WHERE Condition
 } $ conditions = implode ( ' AND ' , $ conditions ) ; //  combine Conditions with AND
 return $ conditions ; }
Builds SQL of given and set Conditions.
@access		protected
@param		array		$conditions		Array of Query Conditions
@param		bool		$usePrimary		Flag: use focused Primary Key
@param		bool		$useForeign		Flag: use focused Foreign Keys
@return		string
Builds SQL of given and set Conditions .