-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
65 lines (39 loc) · 1.64 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Copyright (c) 2009, AF83, All rights reserved
You can ask for help and/or improvements or just say hi on the irc.freenode.org#morm channel
Morm is an attempt to create a nice and as powerfull as possible PHP orm.
For now, Morm can handle:
* Simple Object -> Table mapping
* one to one relations
* one to many relations
* many to many relations (still in early alpha stage though)
* polymorphism
* STI
thanks to the new Mormulous file, you can now use Morm in a very simple manner.
all you have to do is:
edit Mormulous.php
The minimal config you can do is set the DB_NAME and DB_USER constants.
You can also set the other Constants to match your requirements.
Morm is now Usable.
Let's suppose you have a table named "post" in your database with a field called
"name".
You can walk through its content by simply doing
<?php
require_once('Mormulous.php');
$posts = new Mormons('post');
foreach($posts as $post)
{
echo $post->name."\n";
}
--------------------------------------------------------------
You'll see that Morm will automagically generate a Model file called "post.php" in the MODELS_PATH and use it.
As soon as this model has been generated once, you can edit it at your
conveniance.
Be careful if you have a field called "type" in your table.
Morm will try to use the STI and load a class named after the content of this
field. Eventhough Morm tries to guess things and be nice with you as much as
possible, in this case, if the model Morm is looking for does not exist, it will
fail.
If you want to avoid this behavior, just add
protected $sti_field = NULL;
in the corresponding model
Feel free to ask for improvements