Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moodle Error writing to database

Tags:

moodle

I am getting Error writing to database in moodle:

Code:

if (is_siteadmin()) {
class addschedule_form extends moodleform {
function definition () {
  $mform =& $this->_form;
  $mform->addElement('text', 'id', 'Enter ID:');
  $mform->setType('id', PARAM_TEXT);
  $this->add_action_buttons(true, 'submit');
   }
   }

  $ti_form = new addschedule_form();
  $ti_form->get_data(); 
  if ($ti_form->is_cancelled()) {redirect('index.php');}
  if ($recs = $ti_form->get_data()) {
  $deleteit = $DB -> delete_records('DELETE * FROM `mdl_schedules` WHERE id = ' . $recs -> id . '');
  redirect('schedule.php');
   }
   }
else {  }
$ti_form->display();

What could be the reason? Any reference or help will be much appreciated.

Regards

like image 204
MOZ Avatar asked Mar 14 '26 18:03

MOZ


1 Answers

The syntax is

$DB->delete_records('schedules', array('id' => $recs->id));

You might want to keep this open in a tab for reference - https://docs.moodle.org/dev/Data_manipulation_API

like image 144
Russell England Avatar answered Mar 17 '26 07:03

Russell England



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!