protected function where_clause($table, array $conditions=null) {
// We accept nulls in conditions
$conditions = is_null($conditions) ? array() : $conditions;
+
+ if (empty($conditions)) {
+ return array('', array());
+ }
+
// Some checks performed under debugging only
if (debugging()) {
$columns = $this->get_columns($table);
}
$allowed_types = $this->allowed_param_types();
- if (empty($conditions)) {
- return array('', array());
- }
$where = array();
$params = array();
$this->assertSame('ddltablenotexist', $e->errorcode);
}
}
- // And without params.
+
try {
- $records = $DB->get_records('xxxx', array());
+ $records = $DB->get_records('xxxx', array('id' => '1'));
$this->fail('An Exception is missing, expected due to query against non-existing table');
} catch (moodle_exception $e) {
$this->assertInstanceOf('dml_exception', $e);
// The get_records() method generates 2 queries the first time is called
// as it is fetching the table structure.
- $whatever = $DB->get_records($tablename);
+ $whatever = $DB->get_records($tablename, array('id' => '1'));
$this->assertEquals($initreads + 3, $DB->perf_get_reads());
$this->assertEquals($initwrites, $DB->perf_get_writes());