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

[eluser]Bard[/eluser]
Hi, i want to use vbulletin's user table in my project with datamapper but the only problem is, vbulletin doesn't have an id field. It only uses "userid" field. Any suggestions without hacking DM core?

[eluser]WanWizard[/eluser]
No.

This is currently not supported, and the main reason for that is that it's quite a complicated change. If it could be solved with some 'hacking of the core', it would have been supported for quite some time.

I usually work around issues like this by using a view, in which I map the 'userid' column to an 'id' column in the view.

It's on the roadmap for 2.0, with a high priority.

[eluser]Bard[/eluser]
Could you please explain "mapping a field in the view"?

[eluser]WanWizard[/eluser]
[quote author="Bard" date="1345803134"]Could you please explain "mapping a field in the view"?[/quote]
Just to be clear, I'm talking about a database view, not an MVC view.

Code:
CREATE VIEW table.view AS SELECT *, userid AS id FROM table;

You can access a database view as a table (check if your db user has the rights to work with views).

Code:
SELECT * FROM table.view WHERE id = '12';

which works perfectly with a DM model.

[eluser]Maglok[/eluser]
I am once again hitting problems with defining advanced relationships with non-class identifiers. I have looked back to your examples, the datamapper docs and my own code and have no idea why it is once again not working. I think I about understand the meaning of 'class' and 'other_field' now. I am suspecting the name of the class being an issue.

WORKING SCENARIO
Code:
// model Skill
   'class' => array(
     'class' => 'ccclass',
     'join_self_as' => 'skill',
     'join_other_as' => 'class',
     'join_table' => 'ccj_ru_class_skill')

// model CCClass
   'skill' => array(
     'class' => 'skill',
     'join_self_as' => 'class',
     'join_other_as' => 'skill',
     'join_table' => 'ccj_ru_class_skill')

NOT WORKING
Code:
// model Skill
   'class_skills' => array(
     'class' => 'ccclass',
     'other_field' => 'skill',
     'join_self_as' => 'skill',
     'join_other_as' => 'ccclass',
     'join_table' => 'ccj_ru_class_skill')

// model CCClass
   'class_skills' => array(
     'class' => 'skill',
     'other_field' => 'ccclass',
     'join_self_as' => 'ccclass',
     'join_other_as' => 'skill',
     'join_table' => 'ccj_ru_class_skill')

DATABASE
Code:
cc_ru_class_skill
id | ccclass_id | skill_id

OR (tried both)

cc_ru_class_skill
id | class_id | skill_id
ERROR
Code:
DataMapper Error: 'ccclass' is not a valid parent relationship for Skill. Are your relationships configured correctly?

I have tried all the combinations I can for the other_field and all.

[eluser]John Murowaniecki[/eluser]
Dudes, I'm having several problems with something like this:

Code:
SELECT *
FROM sometable
WHERE   somefield BETWEEN 1 AND 3
    AND somefield BETWEEN 6 AND 8
    AND lastfield = 1

is the result for
Code:
$m = new Somemodel();
$m->where_between('somefield', 1, 3);
$m->where_between('somefield', 6, 8);
$m->where('lastfield', 1);

someone know how to do this way?
Code:
SELECT *
FROM sometable
WHERE ( somefield BETWEEN 1 AND 3
    OR  somefield BETWEEN 6 AND 8)
    AND lastfield = 1

since using or_where_between returns data where my `lastfield` isn't 1 someone has an idea?

[eluser]WanWizard[/eluser]
How about
Code:
$m = new Somemodel();
$m
  ->group_start()
    ->where_between('somefield', 1, 3)
    ->or_where_between('somefield', 6, 8)
  ->group_end()
  ->where('lastfield', 1);

[eluser]John Murowaniecki[/eluser]
Man, I'd give you a kiss if I could. It saved my night, I swear I had searched SEEN AND I these functions, but I realize that without the solution lay there. Thanks a lot!

[eluser]willaser[/eluser]
[quote author="WanWizard" date="1329552975"]Oops, indeed something I've missed.

That line should read:
Code:
$select = $this->dm_get('_count_string');
[/quote]

Hello WanWizard, I have used Datamapper on the last stable version of CodeIgniter and everything was right. Now, I have started to use it as spark on PyroCMS and I'm having some issues with 'count()' method.

Firstly, I get this error message:
Code:
Fatal error: Cannot access protected property DM_DB_mysql_driver::$_count_string in /var/www/pyrocms/system/sparks/datamapper/1.8.2/libraries/datamapper.php on line 2518

Then, I try to fix it with the code that you said in the quote:
Code:
$select = $this->db->_count_string;

$select = $this->db->dm_get('_count_string');

and the new error is this:
Code:
Fatal error: Call to undefined method DM_DB_mysql_driver::_protect_identifiers() in /var/www/pyrocms/system/sparks/datamapper/1.8.2/third_party/datamapper/system/DB_driver.php(66) : eval()'d code on line 11

This is the line which trigger the error:
Code:
$sql = $this->db->dm_call_method('_compile_select', $select . $this->db->dm_call_method('_protect_identifiers', 'numrows'));

Greetings!

[eluser]WanWizard[/eluser]
I don't think the spark contains the latest fixes. I tried to update it, but getsparks doesn't understand the 1.8.2.1 version (they only work with 3 digits).

Get the zip from bitbucket instead, and install the latest version manually.




Theme © iAndrew 2016 - Forum software by © MyBB