Doctrine 1.2.4
Doctrine_Query_Condition Class Reference

Inherits Doctrine_Query_Part.

Inherited by Doctrine_Query_Having, Doctrine_Query_JoinCondition, and Doctrine_Query_Where.

Public Member Functions

 getQuery ()
 
 parse ($str)
 
 parseLiteralValue ($value)
 

Detailed Description

Definition at line 33 of file Condition.php.

Member Function Documentation

Doctrine_Query_Part::getQuery ( )
inherited
Returns
Doctrine_Query $query the query object associated with this parser

Definition at line 58 of file Part.php.

{
return $this->query;
}
Doctrine_Query_Condition::parse (   $str)

DQL CONDITION PARSER parses the join condition/where/having part of the query string

Parameters
string$str
Returns
string

Definition at line 42 of file Condition.php.

{
$tmp = trim($str);
$parts = $this->_tokenizer->bracketExplode($str, array(' OR '), '(', ')');
if (count($parts) > 1) {
$ret = array();
foreach ($parts as $part) {
$part = $this->_tokenizer->bracketTrim($part, '(', ')');
$ret[] = $this->parse($part);
}
$r = implode(' OR ', $ret);
} else {
$parts = $this->_tokenizer->bracketExplode($str, array(' AND '), '(', ')');
// Ticket #1388: We need to make sure we're not splitting a BETWEEN ... AND ... clause
$tmp = array();
for ($i = 0, $l = count($parts); $i < $l; $i++) {
$test = $this->_tokenizer->sqlExplode($parts[$i]);
if (count($test) == 3 && strtoupper($test[1]) == 'BETWEEN') {
$tmp[] = $parts[$i] . ' AND ' . $parts[++$i];
} else if (count($test) == 4 && strtoupper($test[1]) == 'NOT' && strtoupper($test[2]) == 'BETWEEN') {
$tmp[] = $parts[$i] . ' AND ' . $parts[++$i];
} else {
$tmp[] = $parts[$i];
}
}
$parts = $tmp;
unset($tmp);
if (count($parts) > 1) {
$ret = array();
foreach ($parts as $part) {
$part = $this->_tokenizer->bracketTrim($part, '(', ')');
$ret[] = $this->parse($part);
}
$r = implode(' AND ', $ret);
} else {
// Fix for #710
if (substr($parts[0],0,1) == '(' && substr($parts[0], -1) == ')') {
return $this->parse(substr($parts[0], 1, -1));
} else {
// Processing NOT here
if (strtoupper(substr($parts[0], 0, 4)) === 'NOT ') {
$r = 'NOT ('.$this->parse(substr($parts[0], 4)).')';
} else {
return $this->load($parts[0]);
}
}
}
}
return '(' . $r . ')';
}
Doctrine_Query_Condition::parseLiteralValue (   $value)

parses a literal value and returns the parsed value

boolean literals are parsed to integers components are parsed to associated table aliases

Parameters
string$valueliteral value to be parsed
Returns
string

Definition at line 110 of file Condition.php.

{
// check that value isn't a string
if (strpos($value, '\'') === false) {
// parse booleans
$value = $this->query->getConnection()
->dataDict->parseBoolean($value);
$a = explode('.', $value);
if (count($a) > 1) {
// either a float or a component..
if ( ! is_numeric($a[0])) {
// a component found
$field = array_pop($a);
$reference = implode('.', $a);
$value = $this->query->getConnection()->quoteIdentifier(
$this->query->getSqlTableAlias($reference). '.' . $field
);
}
}
} else {
// string literal found
}
return $value;
}

The documentation for this class was generated from the following file: