Moodle error in database

I am getting an error to the 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 link or help would be appreciated.

Hello

+3


source to share


1 answer


Syntax

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

      



You might want to keep this open in the link tab - https://docs.moodle.org/dev/Data_manipulation_API

+2


source







All Articles