Fix tests

This commit is contained in:
Timothy Warren 2012-03-09 08:26:16 -05:00
parent 6bd17a2150
commit 913993c963
6 changed files with 20 additions and 11 deletions

View File

@ -162,10 +162,7 @@ abstract class DB_PDO extends PDO {
{ {
if (is_array($ident)) if (is_array($ident))
{ {
for($i = 0, $count = count($ident); $i < $count; $i++) return array_map(array($this, 'quote_ident'), $ident);
{
$ident[$i] = $this->quote_ident($ident[$i]);
}
} }
// Split each identifier by the period // Split each identifier by the period

View File

@ -136,10 +136,7 @@ class MySQL extends DB_PDO {
{ {
if (is_array($ident)) if (is_array($ident))
{ {
for($i = 0, $count = count($ident); $i < $count; $i++) return array_map(array($this, 'quote_ident'), $ident);
{
$ident[$i] = $this->quote_ident($ident[$i]);
}
} }
// Split each identifier by the period // Split each identifier by the period

View File

@ -79,7 +79,9 @@ class Query_Builder {
{ {
$result = $this->db->query($sql); $result = $this->db->query($sql);
} }
elseif ( ! empty($this->select_string))
// Set the select string
if ( ! empty($this->select_string))
{ {
// Replace the star with the selected fields // Replace the star with the selected fields
$sql = str_replace('*', $this->select_string, $sql); $sql = str_replace('*', $this->select_string, $sql);
@ -91,6 +93,8 @@ class Query_Builder {
$sql = $this->sql->limit($sql, $limit, $offset); $sql = $this->sql->limit($sql, $limit, $offset);
} }
//echo $sql."<br />";
return $this->db->query($sql); return $this->db->query($sql);
} }
@ -114,6 +118,7 @@ class Query_Builder {
if (stripos($field, 'as') !== FALSE) if (stripos($field, 'as') !== FALSE)
{ {
$fields_array[$key] = preg_split('`as`i', $field); $fields_array[$key] = preg_split('`as`i', $field);
$fields_array[$key] = array_map('trim', $fields_array[$key]);
} }
} }
@ -121,7 +126,7 @@ class Query_Builder {
$safe_array = array_map(array($this->db, 'quote_ident'), $fields_array); $safe_array = array_map(array($this->db, 'quote_ident'), $fields_array);
// Join the strings back together // Join the strings back together
for($i = 0, $c = count($safe_array); $i < $count; $i++) for($i = 0, $c = count($safe_array); $i < $c; $i++)
{ {
if (is_array($safe_array[$i])) if (is_array($safe_array[$i]))
{ {
@ -131,6 +136,8 @@ class Query_Builder {
$this->select_string = implode(', ', $safe_array); $this->select_string = implode(', ', $safe_array);
//echo $this->select_string."<br />";
return $this; return $this;
} }

View File

@ -154,6 +154,14 @@ class FirebirdTest extends UnitTestCase {
$this->assertTrue(is_resource($query)); $this->assertTrue(is_resource($query));
} }
function TestQBSelectGet()
{
$query = $this->qb->select('id, key as k, val')->get('create_test', 2, 1);
$this->assertTrue(is_resource($query));
}
function TestPreparedStatements() function TestPreparedStatements()
{ {
$sql = <<<SQL $sql = <<<SQL

View File

@ -154,7 +154,7 @@ SQL;
function TestQBSelectGet() function TestQBSelectGet()
{ {
$query = $this->qb->select('id, key as k, val')->get('create_test'); $query = $this->qb->select('id, key as k, val')->get('create_test', 2, 1);
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');

Binary file not shown.