2006-06-30 03:04:39 +04:00
|
|
|
<?php
|
|
|
|
require_once("Condition.php");
|
|
|
|
|
|
|
|
class Doctrine_Query_Where extends Doctrine_Query_Condition {
|
|
|
|
/**
|
2006-07-05 02:36:22 +04:00
|
|
|
* load
|
2006-06-30 03:04:39 +04:00
|
|
|
* returns the parsed query part
|
|
|
|
*
|
|
|
|
* @param string $where
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
final public function load($where) {
|
2006-07-05 02:36:22 +04:00
|
|
|
|
2006-06-30 03:04:39 +04:00
|
|
|
$e = explode(" ",$where);
|
|
|
|
$r = array_shift($e);
|
|
|
|
$a = explode(".",$r);
|
|
|
|
|
|
|
|
|
|
|
|
if(count($a) > 1) {
|
|
|
|
$field = array_pop($a);
|
2006-07-05 02:36:22 +04:00
|
|
|
$count = count($e);
|
|
|
|
$slice = array_slice($e, 0, ($count - 1));
|
|
|
|
$operator = implode(' ', $slice);
|
|
|
|
|
|
|
|
$slice = array_slice($e, -1, 1);
|
|
|
|
$value = implode('', $slice);
|
|
|
|
|
2006-06-30 03:04:39 +04:00
|
|
|
$reference = implode(".",$a);
|
|
|
|
$count = count($a);
|
|
|
|
|
2006-07-05 02:36:22 +04:00
|
|
|
|
2006-06-30 03:04:39 +04:00
|
|
|
$table = $this->query->load($reference, false);
|
|
|
|
$where = $this->query->getTableAlias($reference).".".$field." ".$operator." ".$value;
|
|
|
|
}
|
|
|
|
return $where;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString() {
|
|
|
|
return ( ! empty($this->parts))?implode(" AND ", $this->parts):'';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|