Created
June 17, 2011 09:03
-
-
Save kemo/1031103 to your computer and use it in GitHub Desktop.
and_where_open() / or_where_open() auto removal example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
abstract class Database_Query_Builder_Where extends Kohana_Database_Query_Builder_Where { | |
/** | |
* Closes an open "AND WHERE (...)" grouping. | |
* | |
* @return $this | |
*/ | |
public function and_where_close() | |
{ | |
$copy = end($this->_where); | |
if (end($copy) === '(') | |
{ | |
array_pop($this->_where); | |
} | |
else | |
{ | |
$this->_where[] = array('AND' => ')'); | |
} | |
return $this; | |
} | |
/** | |
* Closes an open "OR WHERE (...)" grouping. | |
* | |
* @return $this | |
*/ | |
public function or_where_close() | |
{ | |
$copy = end($this->_where); | |
if (end($copy) === '(') | |
{ | |
array_pop($this->_where); | |
} | |
else | |
{ | |
$this->_where[] = array('OR' => ')'); | |
} | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment