Part of the EllisLab Network
   
1 of 25
1
Gas ORM
Posted: 23 October 2011 03:00 PM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1544
Joined  12-20-2010

A lighweight and easy-to-use ORM for CodeIgniter. Gas was built specifically for CodeIgniter app. It uses standard CI DB packages, also take anvantages of its validator class. Gas provide methods that will map your database table and its relation, into accesible object.

For download or recent update, look at GasORM @ GitHub. This library also available at Sparks. For guide and example go to Documentation for version 1.x.x.

Requirements

1. PHP v.5.2.x
2. CodeIgniter v.2.x.x

Features

1. Supported databases : cubrid, mssql, mysql, oci8, odbc, postgre, sqlite, sqlsrv.
2. Support multiple database connection.
3. Support modular models directories and sub-models directories.
4. Multiple relationship (has_one, has_many, belongs_to, has_and_belongs_to) with custom relationship setting (through, foreign_key, foreign_table, self).
5. Auto-create models from database tables and vice versa, and auto-synchronize models-tables by creating migrations file.
6 Per-request caching.
7. Self-referential and adjacency column/data (hierarchical data).
8. Eager Loading.
9. Various finder method (can chained with most of CI AR syntax) and aggregates.
10. Validation and auto-mapping input collection, with minimal setup.
11. Hooks points, to control over your model.
12. Extensions, to share your common function/library/helper/plugin across your model instances.
13. Transaction and other CI AR goodness.
14. Command Line Interface.

Planned Features

1. Support for tree traversal data.
More useful features.

NOTE : latest version is v.1.4.3 (also compatible with the latest CI 2.1.0), if you using < v.1.3.0, please update. Also note that Auto-create models from tables and vice versa require CI v.2.1.x

 Signature 

“In Code We Trust.”


CI Library : Gas ORM | Proxy

Profile
 
 
Posted: 24 October 2011 03:34 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  159
Joined  08-15-2010

Two weeks and two new CI orms….what is the world coming to? smile

You guys should all contribute together.

Profile
 
 
Posted: 24 October 2011 11:44 PM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1544
Joined  12-20-2010
JonoB - 24 October 2011 03:34 PM

Two weeks and two new CI orms….what is the world coming to? smile

You guys should all contribute together.

smile JonoB, i dont know what you mean or refer, by stating “two new CI ORMS”. Actually, in CI world, there was already great ORM, which is DataMapper. If i should choose, between Doctrine, PHP AR or that (DataMapper), i will actually choose DataMapper. Because it utilize all CI goodness, rather than bring feoreign packages (a huge one) into your codebase. So, by using semi-native ORM like this(DataMapper, or Gas), you remove yourself from the duplication carried by foreign code/packages from your codebase, such as Doctrine or PHP AR, which each have their own database and validator package(s).

But for some reasons, especially easy-to-use part, i found DataMapper slightly “obsolete” compared with recent popular ORM, in terms how they utilize and make user easier to implement their ORM methods. Thats why for my recent CI app, i create my own. Feel free to submit any issue/bugs you found, and thats why i publish this library for.

Because some user which test it last night, send me a message that they have an issue when running in PHP < 5.3, and i found it because in my initial version, i have some line that passing…

func_get_args(); 

directly as a function’s parameter, and that will fail in PHP under 5.3, so i know whats wrong, and my recent app avoid future potential bugs early.

So when i wrote this (and other library i have in my signature), i have a business case smile

 Signature 

“In Code We Trust.”


CI Library : Gas ORM | Proxy

Profile
 
 
Posted: 25 October 2011 04:48 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  71
Joined  09-05-2007

Just a quick note, when you retrieve a relationship

$user->kid 
that returns no rows, the resulting array is not empty so
count($user->kid

always returns 1.

This behaviour can also be noticed when doing a foreach loop on the same relation.

Also, a way of sorting/ordering the results would be very welcome grin

Stefano

PS I know I am stressing you but I like the fact that your ORM is very lightweight compared to others, so I’d really like to use it in my next projects wink

 Signature 

Visit my CodeIgnited webpage @ http://www.stefanogiordano.it

Profile
 
 
Posted: 25 October 2011 07:28 PM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1544
Joined  12-20-2010

@Stefano, thanks for doing some research/test on it, i appreciate that. I just merge several commits, beside fixes some issue which reported by some user, iam also adding a controller contain unit-testing procedure to performing test : evaluate all available implementation to determine if it is producing the correct data type and result, feel free to submit any issue(s) if you still found any.

 Signature 

“In Code We Trust.”


CI Library : Gas ORM | Proxy

Profile
 
 
Posted: 26 October 2011 04:04 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  71
Joined  09-05-2007

The main issue I still have, is the “empty relations” problem

count($user->kid

that always returns 1 even if the User has no Kids.

 Signature 

Visit my CodeIgnited webpage @ http://www.stefanogiordano.it

Profile
 
 
Posted: 26 October 2011 07:32 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  159
Joined  08-15-2010
toopay - 24 October 2011 11:44 PM
JonoB - 24 October 2011 03:34 PM

Two weeks and two new CI orms….what is the world coming to? smile

You guys should all contribute together.

smile JonoB, i dont know what you mean or refer, by stating “two new CI ORMS”.

http://codeigniter.com/forums/viewthread/202060/

Profile
 
 
Posted: 26 October 2011 11:14 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Avatar
Total Posts:  17
Joined  07-13-2011

Cool work. Thanks.

 Signature 

I love CI !

Send E-mails with Gmail Account:
https://github.com/sineld/CI-Gmail

Profile
 
 
Posted: 26 October 2011 12:48 PM   [ Ignore ]   [ # 8 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1544
Joined  12-20-2010

@Stefano G :
You may notice that because you are try to fetch a child object from a user resources which has one-to-many or many-to-many relationship, you should expect to accept an array (just like if you go with PHP AR, for example). So actually, if you do

var_dump(empty($user->kid));
// Because $user->kid actually contain : array( 0 => FALSE) 

It will returns true, mean that user really didnt have kid smile But you are right, it should be just empty array, so i will ship this fix in next commit maybe in upcoming day.

Also regarding order_by clause, this was easily can achieve by chaining those method (eg:order_by) with one of available finder method (all, find_by_something, etc).

@JonoB, ah, ok.

@sineld, you’re welcome.

 Signature 

“In Code We Trust.”


CI Library : Gas ORM | Proxy

Profile
 
 
Posted: 27 October 2011 01:44 AM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  71
Joined  09-05-2007

Ok thanks I will check the order_by clause, maybe some more examples in the readme file would be great as ordering the results is something really important wink

I’ll wait for the fix also smile

Stefano

 Signature 

Visit my CodeIgnited webpage @ http://www.stefanogiordano.it

Profile
 
 
Posted: 28 October 2011 01:34 AM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  71
Joined  09-05-2007

I can confirm that this fragment actually works as a charm:

$user = new User;
$u1 $user->order_by('is_author''asc')
           ->
order_by('id''desc')
           ->
all();
if (
$user->has_result()) {      
foreach ($u1 as $u)
   
print_r($u->to_array()) ."\n";

Maybe you should mention in the userguide that mixing GAS/CI Active Records clauses DOES work! an ORM library that weights 26Kb is terrific! smile


Stefano

 Signature 

Visit my CodeIgnited webpage @ http://www.stefanogiordano.it

Profile
 
 
   
1 of 25
1