MDL-48595 logstore: Adding new interfaces

sql_reader and sql_internal_table_reader.
This commit is contained in:
David Monllao
2015-03-09 08:25:37 +08:00
parent 45a1a16bfc
commit 1cfce08e63
7 changed files with 388 additions and 74 deletions
+20 -7
View File
@@ -1345,7 +1345,7 @@ class table_sql extends flexible_table {
*/
public $sql = NULL;
/**
* @var array Data fetched from the db.
* @var array|\Traversable Data fetched from the db.
*/
public $rawdata = NULL;
@@ -1374,14 +1374,27 @@ class table_sql extends flexible_table {
* processing each col using either col_{columnname} method or other_cols
* method or if other_cols returns NULL then put the data straight into the
* table.
*
* @return void
*/
function build_table() {
if ($this->rawdata) {
foreach ($this->rawdata as $row) {
$formattedrow = $this->format_row($row);
$this->add_data_keyed($formattedrow,
$this->get_row_class($row));
}
if ($this->rawdata instanceof \Traversable && !$this->rawdata->valid()) {
return;
}
if (!$this->rawdata) {
return;
}
foreach ($this->rawdata as $row) {
$formattedrow = $this->format_row($row);
$this->add_data_keyed($formattedrow,
$this->get_row_class($row));
}
if ($this->rawdata instanceof \core\dml\recordset_walk ||
$this->rawdata instanceof moodle_recordset) {
$this->rawdata->close();
}
}