diff --git a/sys/db/db_pdo.php b/sys/db/db_pdo.php
index 06ecc29..279c2e1 100644
--- a/sys/db/db_pdo.php
+++ b/sys/db/db_pdo.php
@@ -162,10 +162,7 @@ abstract class DB_PDO extends PDO {
{
if (is_array($ident))
{
- for($i = 0, $count = count($ident); $i < $count; $i++)
- {
- $ident[$i] = $this->quote_ident($ident[$i]);
- }
+ return array_map(array($this, 'quote_ident'), $ident);
}
// Split each identifier by the period
diff --git a/sys/db/drivers/mysql.php b/sys/db/drivers/mysql.php
index 80f5fe3..3957dd3 100644
--- a/sys/db/drivers/mysql.php
+++ b/sys/db/drivers/mysql.php
@@ -136,10 +136,7 @@ class MySQL extends DB_PDO {
{
if (is_array($ident))
{
- for($i = 0, $count = count($ident); $i < $count; $i++)
- {
- $ident[$i] = $this->quote_ident($ident[$i]);
- }
+ return array_map(array($this, 'quote_ident'), $ident);
}
// Split each identifier by the period
diff --git a/sys/db/query_builder.php b/sys/db/query_builder.php
index 612b7df..377f4fa 100644
--- a/sys/db/query_builder.php
+++ b/sys/db/query_builder.php
@@ -79,7 +79,9 @@ class Query_Builder {
{
$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
$sql = str_replace('*', $this->select_string, $sql);
@@ -90,6 +92,8 @@ class Query_Builder {
{
$sql = $this->sql->limit($sql, $limit, $offset);
}
+
+ //echo $sql."
";
return $this->db->query($sql);
}
@@ -114,6 +118,7 @@ class Query_Builder {
if (stripos($field, 'as') !== FALSE)
{
$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);
// 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]))
{
@@ -130,6 +135,8 @@ class Query_Builder {
}
$this->select_string = implode(', ', $safe_array);
+
+ //echo $this->select_string."
";
return $this;
}
diff --git a/tests/databases/firebird.php b/tests/databases/firebird.php
index 9c4272f..e96b275 100644
--- a/tests/databases/firebird.php
+++ b/tests/databases/firebird.php
@@ -154,6 +154,14 @@ class FirebirdTest extends UnitTestCase {
$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()
{
$sql = <<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');
diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB
index f7e36f7..7dcb545 100755
Binary files a/tests/test_dbs/FB_TEST_DB.FDB and b/tests/test_dbs/FB_TEST_DB.FDB differ