summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Holywell <[email protected]>2014-05-28 15:20:44 +0100
committerSimon Holywell <[email protected]>2014-05-28 15:20:44 +0100
commita1b30b9a8889110e5e6bbad06efe36ed0454468a (patch)
treeb3a2d447307c37fe5214417de62d23d8b1d748ec
parentddb8a305a59592101f8fd08060a67bb100393fa1 (diff)
parentc4cc6a47f6d4333587e991614ea253b354828e60 (diff)
Merge pull request #197 from kendru/issue176
Correct issue #176: Ensure database setup before building select
-rw-r--r--idiorm.php1
-rw-r--r--test/QueryBuilderTest.php10
2 files changed, 9 insertions, 2 deletions
diff --git a/idiorm.php b/idiorm.php
index ed22d8b..ae97e01 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -233,6 +233,7 @@
* @return ORM
*/
public static function for_table($table_name, $connection_name = self::DEFAULT_CONNECTION) {
+ self::_setup_db($connection_name);
return new self($table_name, array(), $connection_name);
}
diff --git a/test/QueryBuilderTest.php b/test/QueryBuilderTest.php
index 3a4a997..3f71bb3 100644
--- a/test/QueryBuilderTest.php
+++ b/test/QueryBuilderTest.php
@@ -631,8 +631,14 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
}
public function testIssue176LimitDoesntWorkFirstTime() {
- $rs = ORM::for_table('position')->limit(1)->find_array();
- $expected = "SELECT * FROM `position` LIMIT 1";
+ ORM::reset_config();
+ ORM::reset_db();
+
+ ORM::configure('logging', true);
+ ORM::configure('connection_string', 'sqlite::memory:');
+
+ ORM::for_table('sqlite_master')->limit(1)->find_array();
+ $expected = "SELECT * FROM `sqlite_master` LIMIT 1";
$this->assertEquals($expected, ORM::get_last_query());
}
}