Originals is a table in the database, it contains one of each type of
thing you wish to be able to clone into the clones table.
MyActiveRecord creates a PHP class for each table you "wrap" it
around, and each row of the table becomes an object of that class when
you request it through MAR.
In short, this line:
if($master = MyActiveRecord::FindById('originals',$original)){
...if it finds a table called 'originals' in your database, will
return the row with the ID matching $original (or false).
Walter
On Jun 29, 2009, at 12:25 PM, WLQ wrote:
>
> It says - Class originals does not exist
> Where does the originals class comes from? What is the originals from
> the code above?
>
>
>> If this is the code you are using (and I've added the missing close
>> parenthesis), then the fact that you are getting a 200 back (and a
>> new
>> ID) means that you have successfully created a new clone. Otherwise,
>> you should be getting a 500 or 404 back.
>>
>> //create_clone.php
>> $original = $_POST['original'];
>> if($master = MyActiveRecord::FindById('originals',$original)){
>> $data = get_object_vars($original);
>> array_shift($data); //get rid of the ID
>> $new = MyActiveRecord::Create('clones',$data);
>> $new->save();
>> if(false === $new->get_errors()){
>> header('Content-type: text/html; charset=utf-8');
>> //this is the part you need:
>> print 'item_' . $new->id;
>> }else{
>> header('HTTP/1.0 500 Server Error',true,500);
>> exit;
>> }}else{
>>
>> header('HTTP/1.0 404 Missing',true,404);
>>
>> }
>>
>> Visit your test page with Firefox and with the Console tab of Firebug
>> open. Make sure Firebug is set to show XHR transactions. You should
>> be
>> able to observe the request to create_clone, and see the reply from
>> the server. The reply should be the new ID of your clone. If it
>> isn't,
>> then you have more debugging to do.
>>
>> Things to check here:
>>
>> * Have you included/required the library (MyActiveRecord) in this
>> script, and have you defined the constants it needs (MySQL address
>> and
>> credentials, also known as a DSN).
>> * Have you got a MySQL table called clones?
>> * Have you enabled error reporting on your server for your test
>> pages,
>> so you can see the PHP errors as they whiz by?
>> * Have you ordered that fat book I recommended?
>>
>> Debugging PHP is like playing Whack-a-Mole. You fix one thing, and
>> another pops up. You iterate, in other, more dainty words.
>>
>> Walter
>>
>> On Jun 28, 2009, at 12:04 PM, WLQ wrote:
>>
>>> Also I've used that clone.php you gave, the only thing it doesn't do
>>> is change the MySQL table itself.
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---