mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +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
|
@ -741,16 +741,15 @@ class mysqli_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;
|
||||
}
|
||||
$dataobject = (array)$dataobject;
|
||||
|
||||
$columns = $this->get_columns($table);
|
||||
|
||||
unset($dataobject->id);
|
||||
$cleaned = array();
|
||||
|
||||
foreach ($dataobject as $field=>$value) {
|
||||
if ($field === 'id') {
|
||||
continue;
|
||||
}
|
||||
if (!isset($columns[$field])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -771,7 +770,7 @@ class mysqli_native_moodle_database extends moodle_database {
|
|||
* @throws dml_exception if error
|
||||
*/
|
||||
public function import_record($table, $dataobject) {
|
||||
$dataobject = (object)$dataobject;
|
||||
$dataobject = (array)$dataobject;
|
||||
|
||||
$columns = $this->get_columns($table);
|
||||
$cleaned = array();
|
||||
|
@ -795,9 +794,8 @@ class mysqli_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.');
|
||||
}
|
||||
|
@ -842,9 +840,7 @@ class mysqli_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