start of like method implementation

This commit is contained in:
Timothy Warren 2012-03-13 19:37:24 -04:00
parent 8a040a2b45
commit 521c0d32da
2 changed files with 33 additions and 3 deletions

View File

@ -248,8 +248,6 @@ abstract class DB_PDO extends PDO {
* Abstract parent for database manipulation subclasses
*/
abstract class DB_SQL {
/**
* Get database-specific sql to create a new table

View File

@ -165,7 +165,39 @@ class Query_Builder {
*/
public function like($field, $val, $pos='both')
{
// @todo implement like method
// @todo Add to where string in the appropriate location
$field = $this->db->quote_ident($field);
$this->like_array[$field] = array(
'value' => $val,
'pos' => $post
);
$likes = array();
foreach($this->like_array as $field => $array)
{
$l = $field. ' LIKE ';
if ($pos == 'before')
{
$l .= '%?';
}
elseif ($pos == 'after')
{
$l .= '?%';
}
else
{
$l .= '%?%';
}
$likes[] = $l;
}
$this->like_string = implode(' AND ', $likes);
return $this;
}