Started query queue with like method

This commit is contained in:
Timothy Warren 2012-03-13 20:04:18 -04:00
parent 521c0d32da
commit 3f7236c706
4 changed files with 25 additions and 26 deletions

View File

@ -24,7 +24,6 @@ class Query_Builder {
private $select_string,
$from_string,
$where_string,
$like_string,
$insert_string,
$update_string,
$set_string,
@ -46,6 +45,9 @@ class Query_Builder {
// Alias to $this->db->sql
private $sql;
// Query component order mapping
private $query_map;
/**
* Constructor
*
@ -165,8 +167,6 @@ class Query_Builder {
*/
public function like($field, $val, $pos='both')
{
// @todo Add to where string in the appropriate location
$field = $this->db->quote_ident($field);
$this->like_array[$field] = array(
@ -174,29 +174,28 @@ class Query_Builder {
'pos' => $post
);
$likes = array();
// Add the like string into the order map
$l = $field. ' LIKE ';
foreach($this->like_array as $field => $array)
if ($pos == 'before')
{
$l = $field. ' LIKE ';
if ($pos == 'before')
{
$l .= '%?';
}
elseif ($pos == 'after')
{
$l .= '?%';
}
else
{
$l .= '%?%';
}
$likes[] = $l;
$l .= '%?';
}
elseif ($pos == 'after')
{
$l .= '?%';
}
else
{
$l .= '%?%';
}
$this->like_string = implode(' AND ', $likes);
$this->query_map[] = array(
'type' => 'like',
'conjunction' => (empty($this->query_map)) ? 'WHERE ' : ' AND ',
'string' => $l,
'value' => $val
);
return $this;
}
@ -712,7 +711,7 @@ class Query_Builder {
break;
}
echo $sql.'<br />';
//echo $sql.'<br />';
return $sql;
}

View File

@ -32,7 +32,7 @@ class FirebirdQBTest extends UnitTestCase {
$params->pass = 'masterkey';
$this->qb = new Query_Builder($params);
echo '<hr /> Firebird Queries <hr />';
//echo '<hr /> Firebird Queries <hr />';
}
function TestGet()

View File

@ -28,7 +28,7 @@
$params->host = 'localhost';
$this->qb = new Query_Builder($params);
echo '<hr /> SQLite Queries <hr />';
//echo '<hr /> SQLite Queries <hr />';
}
function TestGet()

Binary file not shown.