Skip to content

af83/morm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
* FullText search with Sphinx (http://www.sphinxsearch.com/)

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

Releases

No releases published

Packages

No packages published

Languages