New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3 fix cache regex #492

Merged
merged 1 commit into from Feb 19, 2012
Jump to file or symbol
Failed to load files and symbols.
+20 −1
Diff settings

Always

Just for now

@@ -420,7 +420,7 @@ function fetchAll($sql, $cache = true, $modelName = null) {
}
if ($cache) {
if (strpos(trim(strtolower($sql)), 'select') !== false) {
if (preg_match('/^\s*select/i', $sql)) {
$this->_queryCache[$sql] = $out;
}
}
@@ -4250,6 +4250,25 @@ function testFetchAllBooleanReturns() {
$this->assertTrue($result, 'Query did not return a boolean. %s');
}
/**
* test that query propery caches/doesn't cache selects
*
* @return void
* @author David Kullmann
*/
function testFetchAllCaching() {
$query = "SELECT NOW() as TIME";
$result = $this->db->fetchAll($query);
$this->assertTrue(is_array($this->db->_queryCache[$query]));
$this->assertEqual($this->db->_queryCache[$query][0][0]['TIME'], $result[0][0]['TIME']);
$query = "DROP TABLE IF EXISTS select_test";
$result = $this->db->fetchAll($query);
$this->assertTrue(!isset($this->db->_queryCache[$query]));
}
/**
* test ShowQuery generation of regular and error messages
*
ProTip! Use n and p to navigate between commits in a pull request.