title: Moodle unable to insert record into database php
body: <p>I have an object which I am trying to insert into a database using Moodle 2.2 LMS </p>
  
  <p>Here is the Object:</p>
  
  <pre><code>object(object)#269 (17) { ["username"]=&gt; string(5) "missk" ["password"]=&gt; string(16) "BydPDczdwXumhd3S" ["firstname"]=&gt; string(6) "Khutso" ["lastname"]=&gt; string(7) "Mosehla" ["email"]=&gt; string(18) "mosehlak@gmail.com" ["confirmed"]=&gt; int(1) ["lang"]=&gt; string(2) "en" ["firstaccess"]=&gt; int(1375184781) ["mnethostid"]=&gt; string(1) "3" ["secret"]=&gt; string(15) "wNGTybC3x2rPZHO" ["auth"]=&gt; string(4) "soap" ["profile_field_saicaid"]=&gt; string(8) "20052064" ["profile_field_prefix"]=&gt; string(2) "Ms" ["profile_field_membertype"]=&gt; string(3) "TEE" ["profile_field_ssocountry"]=&gt; string(12) "South Africa" ["profile_field_ssocity"]=&gt; string(14) "KWATHEMA EXT 2" ["profile_field_ssoregion"]=&gt; string(5) "North" }
  </code></pre>
  
  <p>When I try and insert the record using this syntax it fails.</p>
  
  <pre><code>$nuser-&gt;id = $DB-&gt;insert_record('user',$nuser);
  </code></pre>
  
  <p>According to the manual, this is the correct syntax.  I have global $CFG and $DB
  The insert simply fails and the script stops at this point.</p>