views:

194

answers:

1

I'm using the "join_table" function with Kohana's ORM to build a query. The following works:

$category = ORM::factory('category')->join_table('product');

But this doesn't:

$category = ORM::factory('category');
$category->join_table('product');

The documentation uses the second as an example, but it returns 0 while the first example returns "categories_products" which is correct. Any ideas?

+2  A: 

I use Kohana, but I'm not familiar with its ORM. The problem with what you're asking is I don't see how it's possible on the php level. Those 2 statements are identical regardless of how they are implemented in Kohana. How exactly are you checking the return value of the second function?

Notice that in the second example, you aren't assigning $category to the return value of join_table like you are in the first one. Could that be your problem?

ryeguy
+1 Just beat me to it :)
Cocowalla
to find the value, I'm using "return $category". What do you mean "you aren't assigning $category to the return value of join_table like you are in the first one"?
anthony
@anthony In your first example, whatever `join_table` returns is assigned to `$category`. In your second example, `$category` contains the return value of `ORM::factory()`. To make these examples equivalent, change the second line of your second example to this: `$category = $category->join_table('product');`.
ryeguy