PHP ActiveRecord version0 release5
3 de June, 2008Here is a new version of the php activerecord i hope you like.
Here is a new version of the php activerecord i hope you like.
Here is my own version of the Active Record pattern for PHP and MySQL. As you can see the class is a little rudimentary but the idea was to do something simple that work always.
How to use it?
Simple extend your model from the Active Record class
Example
Table 1:
Members
* id
* name
* email
Table 2:
Posts
* id
* title
* member_id
File 1: member.php
class Member extends ActiveRecord
{
var $has_many = array("Posts");
}
File 2: post.php
class Post extends ActiveRecord
{
var $belongs_to = array("Member");
}
File 3: index.php
< ?php
$member = Member::new_instance('Member');
$member->find(’All’); // returns a member object array
$member->find(3); // set meber where id=3
$member->Posts; // returns a post object array
?>
I really wanted to write something better, but first English is no my nature Language, and second is 2:41 am. So when I found a little time I will update the info, meanwhile if you want you can put you review at the comments section
Click
here to download the fireworks form autoshape