I'm trying to learn how to add and delete records using Active Record.

This works to add:

$instance = new Calendar37Record;
$instance->timestr = $timestr;
$success = $instance->save();

Given that I know the id of the record to delete, is the process to find the record and then delete it? Or can you just delete it? I tried this, but it doesn't seem to find the record, and it complains 'The active record cannot be deleted because it is new.':

$instance = new Calendar37Record;
$success = $instance->delete(); 

Thank you for any help!


Have you tried

$instance = new Calendar37Record;
  • 1
    Works! Thank you. I think I shouldn't stay up so late at night.
    – kr37
    Jun 11 '15 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.