Started query queue with like method
This commit is contained in:
parent
521c0d32da
commit
3f7236c706
@ -24,7 +24,6 @@ class Query_Builder {
|
|||||||
private $select_string,
|
private $select_string,
|
||||||
$from_string,
|
$from_string,
|
||||||
$where_string,
|
$where_string,
|
||||||
$like_string,
|
|
||||||
$insert_string,
|
$insert_string,
|
||||||
$update_string,
|
$update_string,
|
||||||
$set_string,
|
$set_string,
|
||||||
@ -46,6 +45,9 @@ class Query_Builder {
|
|||||||
// Alias to $this->db->sql
|
// Alias to $this->db->sql
|
||||||
private $sql;
|
private $sql;
|
||||||
|
|
||||||
|
// Query component order mapping
|
||||||
|
private $query_map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -165,8 +167,6 @@ class Query_Builder {
|
|||||||
*/
|
*/
|
||||||
public function like($field, $val, $pos='both')
|
public function like($field, $val, $pos='both')
|
||||||
{
|
{
|
||||||
// @todo Add to where string in the appropriate location
|
|
||||||
|
|
||||||
$field = $this->db->quote_ident($field);
|
$field = $this->db->quote_ident($field);
|
||||||
|
|
||||||
$this->like_array[$field] = array(
|
$this->like_array[$field] = array(
|
||||||
@ -174,10 +174,7 @@ class Query_Builder {
|
|||||||
'pos' => $post
|
'pos' => $post
|
||||||
);
|
);
|
||||||
|
|
||||||
$likes = array();
|
// Add the like string into the order map
|
||||||
|
|
||||||
foreach($this->like_array as $field => $array)
|
|
||||||
{
|
|
||||||
$l = $field. ' LIKE ';
|
$l = $field. ' LIKE ';
|
||||||
|
|
||||||
if ($pos == 'before')
|
if ($pos == 'before')
|
||||||
@ -193,10 +190,12 @@ class Query_Builder {
|
|||||||
$l .= '%?%';
|
$l .= '%?%';
|
||||||
}
|
}
|
||||||
|
|
||||||
$likes[] = $l;
|
$this->query_map[] = array(
|
||||||
}
|
'type' => 'like',
|
||||||
|
'conjunction' => (empty($this->query_map)) ? 'WHERE ' : ' AND ',
|
||||||
$this->like_string = implode(' AND ', $likes);
|
'string' => $l,
|
||||||
|
'value' => $val
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -712,7 +711,7 @@ class Query_Builder {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $sql.'<br />';
|
//echo $sql.'<br />';
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class FirebirdQBTest extends UnitTestCase {
|
|||||||
$params->pass = 'masterkey';
|
$params->pass = 'masterkey';
|
||||||
$this->qb = new Query_Builder($params);
|
$this->qb = new Query_Builder($params);
|
||||||
|
|
||||||
echo '<hr /> Firebird Queries <hr />';
|
//echo '<hr /> Firebird Queries <hr />';
|
||||||
}
|
}
|
||||||
|
|
||||||
function TestGet()
|
function TestGet()
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
$params->host = 'localhost';
|
$params->host = 'localhost';
|
||||||
$this->qb = new Query_Builder($params);
|
$this->qb = new Query_Builder($params);
|
||||||
|
|
||||||
echo '<hr /> SQLite Queries <hr />';
|
//echo '<hr /> SQLite Queries <hr />';
|
||||||
}
|
}
|
||||||
|
|
||||||
function TestGet()
|
function TestGet()
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user