Skip to content

Commit

Permalink
ongoing doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mstdokumaci committed May 23, 2012
1 parent 215bee9 commit 30ce7b3
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion doc/readme.md
Expand Up @@ -2,7 +2,7 @@

I've seen many PHP ORM libraries. Most of them makes you write a new class for each item you want to keep in DB. This seems repetition of same things to me. Extending this, extending that for no different logic.

Items have fields of data in similar kind and have similar relations among. So a well-written class can be used for all. If you need somthing makes things easier, this is my approach.
Items have fields of data in similar kind and have similar relations among. So a well-written class can be used for all. If you need a library which makes things easier, this is my approach.

arrayDB ORM library has only 5 classes. You mostly use a singleton of one, others used internally, that's all. Caching and keeping cache synchronised with DB is all automated. You don't need to keep track of these.

Expand All @@ -12,3 +12,32 @@ To start using this library, you have to do 3 simple definitions.
- Define your MySQL access.
- Define your cache config.

## Defining data model

All data model definiton is writing down an array like this:

$model=array(
'user'=>array(
'conf'=>array('len'=>7),
'fields'=>array(
'name'=>array('len'=>50)
),
'has_many'=>array(
'posts'=>array('type'=>'post', 'foreign_name'=>'writer')
),
'many_to_many'=>array(
'liked_posts'=>array('type'=>'post', 'foreign_name'=>'liker'),
)
),

'post'=>array(
'conf'=>array('len'=>10),
'fields'=>array(
'text'=>array('len'=>200)
)
)
);

We have 2 items here. User and post. Users has names, many written posts and many liked posts. Posts has texts and likers.

With this model, we want to

0 comments on commit 30ce7b3

Please sign in to comment.