Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 17th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. What should I do with the database when I create a course in PHP with Moodle?
  2. public function createCourse()
  3. {
  4.     //find category
  5.     //calculate sortorder i.e. search in mdl course for all course with category. select sortorder MAX then ++
  6.     require "/mysqli_connect.php";
  7.     $t = time();
  8.     $insert_q = "INSERT INTO mdl_course
  9.     (category, fullname, shortname, summary, startdate, maxbytes,
  10.     timecreated, newsitems, numsections, expirythreshold)
  11.     VALUES (30, 'Fullname', 'shortname', 'This is the summary', '$t', 268435456, '$t', 5, 10, 864000)";
  12.  
  13.     $insert_r = mysqli_query($mysqli, $insert_q);
  14.     $insert_n = mysqli_affected_rows($mysqli);
  15.     //var_dump($insert_n);
  16.     if($insert_n == 1)
  17.     {
  18.         return true; //insert successful
  19.     }
  20.     else
  21.     {
  22.         return false;
  23.     }      
  24. }