Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.0

[eluser]rherriman[/eluser]
I understand the notion of junctions, of course. I just didn't understand why defining a reciprocal relationship must STILL interpret the relationship as one way, as opposed to $product->related->get() using a UNION to filter the products like so:

Code:
SELECT products.* FROM products LEFT JOIN products_products ON products.id = products_products.product_id WHERE products_products.related_id = 10
UNION
SELECT products.* FROM products LEFT JOIN products_products ON products.id = products_products.related_id WHERE products_products.product_id = 10

Saving the "inverse" relationship as well just seems like an unnecessary waste. That's all I'm trying to say.

[eluser]IgnitedCoder[/eluser]
Why oh why oh why?

Works just fine when I use Apache2, but Nginx it just won't work. I've got both servers setup Apache and nginx. I stop nginx, start apache and run the same code and no issues, stop apache, start nginx and this shows up. Here's the kicker... its a simple model

Code:
class User extends DataMapper{

var $has_one = array('profile');

}

Fatal error: Call to a member function field_data() on a non-object in /home/devwebtalk/workspace/www/dev/system/database/DB_driver.php on line 889

Please help...

Oh its PHP 5.3.3, MySQL 5.1, apache 2 and now nginx 1.0 with PHP-FLM, which outperforms apache big time. We're expecting millions of hits and we need a comet server which nginx supports very well so I have to get DM working for this. Please help WanWizard! Smile

[eluser]WanWizard[/eluser]
@rherriman,

An ORM is about objects, and relationships between them. And not about writing the most optimal SQL for every question you can think of. Nobody's stopping you from adding a method to your Product model that runs a custom query.
Code:
function mycustommethod($where)
{
    // run some kind of query
    $query = $this->db->get_where($this->table, $where);

    // convert the result into DM objects
    if ($query)
    {
        $this->_process_query($query);
    }
}

[eluser]WanWizard[/eluser]
@BrendanRehman,

That's an error in the CI database driver, so not related (directly) to Datamapper.

DB_Driver's field_data() method runs a query, and expects a DB_Result object in return. It then calls the field_data() method of that object to get the table information.
The query that runs is "SELECT * FROM table LIMIT 1", not exactly complicated.

Assuming you autoload your database library, could you add this at the top of a controller method you can call?
Code:
// replace table by a valid table name
$query = $this->db->query('SELECT * FROM table LIMIT 1');
var_dump($this->db->last_query());
var_dump($query);
Do you get a proper result?

[eluser]IgnitedCoder[/eluser]
@WanWizard,

Here's what came back from the call. Looks right... Is this a bug in CI I need to report!

Code:
string(27) "SELECT * FROM users LIMIT 1" object(CI_DB_mysql_result)#33 (8) { ["conn_id"]=> resource(31) of type (mysql link) ["result_id"]=> resource(64) of type (mysql result) ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(1) ["row_data"]=> NULL }

[eluser]IgnitedCoder[/eluser]
@WanWizard, I found the issue... turns out one of the developers added a new field to a table on his local machine, uploaded the new code and of course his code was looking for a field that didn't exist on the server. AGGGHHH I wish error messages were clearer!

[eluser]WanWizard[/eluser]
Shall I add a "Something not found. Please smack your developer" message? Smile

[eluser]IgnitedCoder[/eluser]
Smile Please do so as an easter egg in DM... that only a few know how to call. My only concern would be when I'm the developer that needs to get smacked. LOL

[eluser]Maucomix[/eluser]
The download link is not working =[

[eluser]WanWizard[/eluser]
Should be fixed again.

My server was down, and I'm out of the country at the moment. Took some time to find someone to fix the issue...




Theme © iAndrew 2016 - Forum software by © MyBB