mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-23568 parameters of DML function insert_record are not modified any more < improved coding style, now using cast to array consistently
This commit is contained in:
parent
97c65be564
commit
d8fa8e406e
6 changed files with 45 additions and 74 deletions
|
@ -986,16 +986,15 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
|||
* @throws dml_exception if error
|
||||
*/
|
||||
public function insert_record($table, $dataobject, $returnid = true, $bulk = false) {
|
||||
if (!is_object($dataobject)) {
|
||||
$dataobject = (object)$dataobject;
|
||||
}
|
||||
|
||||
unset($dataobject->id);
|
||||
$dataobject = (array)$dataobject;
|
||||
|
||||
$columns = $this->get_columns($table);
|
||||
$cleaned = array ();
|
||||
|
||||
foreach ($dataobject as $field => $value) {
|
||||
if ($field === 'id') {
|
||||
continue;
|
||||
}
|
||||
if (!isset($columns[$field])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1054,9 +1053,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
|||
* @throws dml_exception if error
|
||||
*/
|
||||
public function update_record_raw($table, $params, $bulk = false) {
|
||||
if (!is_array($params)) {
|
||||
$params = (array)$params;
|
||||
}
|
||||
$params = (array)$params;
|
||||
|
||||
if (!isset($params['id'])) {
|
||||
throw new coding_exception('moodle_database::update_record_raw() id field must be specified.');
|
||||
|
@ -1098,9 +1095,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
|||
* @throws dml_exception if error
|
||||
*/
|
||||
public function update_record($table, $dataobject, $bulk = false) {
|
||||
if (!is_object($dataobject)) {
|
||||
$dataobject = (object)$dataobject;
|
||||
}
|
||||
$dataobject = (array)$dataobject;
|
||||
|
||||
$columns = $this->get_columns($table);
|
||||
$cleaned = array ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue