Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 172... Línea 172...
172
     * Factory method which uses the parameters to retrieve all matching instances from the database
172
     * Factory method which uses the parameters to retrieve all matching instances from the database
173
     *
173
     *
174
     * @param string $table The table to retrieve from
174
     * @param string $table The table to retrieve from
175
     * @param string $classname The name of the class to instantiate
175
     * @param string $classname The name of the class to instantiate
176
     * @param array $params An array of conditions like $fieldname => $fieldvalue
176
     * @param array $params An array of conditions like $fieldname => $fieldvalue
-
 
177
     * @param string $sortby The SQL sort order. E.g. 'id ASC'
177
     * @return array|bool Array of object instances or false if not found
178
     * @return array|bool Array of object instances (sorted by $sortby) or false if not found
178
     */
179
     */
179
    public static function fetch_all_helper($table, $classname, $params) {
180
    public static function fetch_all_helper($table, $classname, $params, string $sortby = 'id ASC') {
180
        global $DB; // Need to introspect DB here.
181
        global $DB; // Need to introspect DB here.
Línea 181... Línea 182...
181
 
182
 
Línea 182... Línea 183...
182
        $instance = new $classname();
183
        $instance = new $classname();
Línea 215... Línea 216...
215
        } else {
216
        } else {
216
            $wheresql = implode("AND", $wheresql);
217
            $wheresql = implode("AND", $wheresql);
217
        }
218
        }
Línea 218... Línea 219...
218
 
219
 
219
        global $DB;
220
        global $DB;
220
        $rs = $DB->get_recordset_select($table, $wheresql, $newparams);
221
        $rs = $DB->get_recordset_select($table, $wheresql, $newparams, $sortby);
221
        //returning false rather than empty array if nothing found
222
        //returning false rather than empty array if nothing found
222
        if (!$rs->valid()) {
223
        if (!$rs->valid()) {
223
            $rs->close();
224
            $rs->close();
224
            return false;
225
            return false;
Línea 427... Línea 428...
427
    /**
428
    /**
428
     * Handles adding feedback files in the gradebook.
429
     * Handles adding feedback files in the gradebook.
429
     *
430
     *
430
     * @param int|null $historyid
431
     * @param int|null $historyid
431
     */
432
     */
432
    protected function add_feedback_files(int $historyid = null) {
433
    protected function add_feedback_files(?int $historyid = null) {
433
    }
434
    }
Línea 434... Línea 435...
434
 
435
 
435
    /**
436
    /**
436
     * Handles updating feedback files in the gradebook.
437
     * Handles updating feedback files in the gradebook.
437
     *
438
     *
438
     * @param int|null $historyid
439
     * @param int|null $historyid
439
     */
440
     */
440
    protected function update_feedback_files(int $historyid = null) {
441
    protected function update_feedback_files(?int $historyid = null) {
Línea 441... Línea 442...
441
    }
442
    }
442
 
443
 
443
    /**
444
    /**