EllisLab text mark
Advanced Search
18 of 18
18
   
Gas ORM
Posted: 25 August 2012 08:27 PM   [ Ignore ]   [ # 261 ]   [ Rating: 0 ]
Avatar
Joined: 2012-06-09
82 posts

I also tried this one and its giving me the results I wanted:

$all_users Model\User::all();

                foreach (
$all_users as $some_user)
                
{
                        
echo 'User ' .$some_user->username.' and he seems have several kids:';

                        foreach (
$some_user->blog() as $blog)
                        
{
                            
echo '<br>';
                            echo 
'<br>';
                            echo 
'<br>';
                            echo 
'<br>';
                            echo 
$blog->title ;
                            echo 
'<br>';
                            echo 
'<br>';
                            echo 
'<br>';
                            echo 
'<br>';
                        
}

                } 

But the problem is its making this queries:

0.0004    SELECT *
FROM (`user`) 
0.0004    SELECT FROM `blogWHERE `blog`.`user_idIN (2
0.0003    SELECT FROM `blogWHERE `blog`.`user_idIN (1

It always makes a new query for fetching the blog posts of EACH user. Which is not good for performance, so I really wanted to use eager loading like this one:

$all_users Model\User::with('blog')->all(); 

I hope you can resolve the problem. Thanks smile

 

 

 
Posted: 29 August 2012 03:19 AM   [ Ignore ]   [ # 262 ]   [ Rating: 0 ]
Joined: 2012-08-28
10 posts

Hi! I’m trying to use Gas ORM but I’m stuck with a many-to-many relationship.

I’ve two tables A, B linked by a third C table

A fields[idname]
B fields
[idname]
C fileds
[ida_idb_idvalue] 

on C table, a_id and b_id are FK to related tables.

What I’m trying to do is to get for each A item, his name, the name of related B items plus the value from C table.

E.g.

JohnRed10
John
Blue12
Mike
Red11 

This is how I’ve defined relationships

In A model:

self::$relationships = array(
    
'a'  => ORM::has_many('\\Model\\B\\A => \\Model\\A')
); 

In B model:

self::$relationships = array(
    
'b'  => ORM::has_many('\\Model\\B\\A => \\Model\\B')
); 

In C model:

self::$relationships = array(
    
'b' => ORM::belongs_to('\\Model\\B'),
    
'a' => ORM::belongs_to('\\Model\\A'),
); 

Then I get some data using this code:

$data['items'Model\A::with('b')->all(); 

So I can use it into view

foreach ($items as $a{
    
foreach ($a->b() as $b{
        
// Here I need to show the value field from C table
    
}

And now the question, does this query $data[‘items’] = Model\A::with(‘b’)->all(); retrieves C table data too?

 
Posted: 30 August 2012 12:31 PM   [ Ignore ]   [ # 263 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-20
1586 posts

No. But you could specify has_many C relationship in your A entity. Btw, this is thread for older version, go to this thread if you have further question on Gas ORM 2.

 Signature 

“In Code We Trust.”


CI Library : Gas ORM | Proxy

 
Posted: 05 September 2012 11:53 AM   [ Ignore ]   [ # 264 ]   [ Rating: 0 ]
Joined: 2008-11-12
4 posts

Hi,

Just like to know if its possible to use memcache for the caching Gas is doing?

 
Posted: 04 October 2012 01:46 PM   [ Ignore ]   [ # 265 ]   [ Rating: 0 ]
Joined: 2011-03-15
4 posts

I found a bug.
If you use join with limit conditions. Limit is return 0.
Example:

//some code...
$results Gas::factory('sections')->select('sections.*, buildings.name as bname, directions.name as dname')
                 ->
order_by($sortname$sortorder)
   ->
left_join_buildings('buildings.id = sections.building_id')
   ->
left_join_directions('directions.id = sections.direction_id')
   ->
limit($limit$offset)
   ->
all();
echo 
Gas::factory('sections')->last_sql();

//result
SELECT ... LIMIT 0 

I’m fixed. In file Gas.php line 5097.

//add code: and $type != 'limit' after $node
if ( ! in_array($type$preserve) and $type == $node and $type != 'limit')
{
    
//...

Sorry for my EL.

 
Posted: 04 October 2012 02:21 PM   [ Ignore ]   [ # 266 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-20
1586 posts

@lnguyen, thanks.

 Signature 

“In Code We Trust.”


CI Library : Gas ORM | Proxy

 
Posted: 31 October 2012 12:29 PM   [ Ignore ]   [ # 267 ]   [ Rating: 0 ]
Joined: 2011-10-16
4 posts

http://gasorm-doc.taufanaditya.com/validation.html#timestamp-fields

Why does GasORM use “12-hour format of an hour with leading zeros” is this a mistake or by purpose?

 
Posted: 31 October 2012 02:56 PM   [ Ignore ]   [ # 268 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-20
1586 posts

Its a mistake. Already spotted, fixed and merged into recent codebase three months ago

 Signature 

“In Code We Trust.”


CI Library : Gas ORM | Proxy

 
Posted: 28 March 2013 05:56 AM   [ Ignore ]   [ # 269 ]   [ Rating: 0 ]
Joined: 2013-02-11
15 posts

Hi, i tried to do an auto-create models from database, it does the “SHOW TABLES FROM `database` ” but it doesn’t generate the models

i set the migration lib config to TRUE and the auto_create_models to TRUE, but no models generated… any idea ?

——

I found the problem. Now new problem, it show me

Messagemkdir() [function.mkdir]No such file or directory 

there are lot of relations in my table if that helps to understand.

 
18 of 18
18