CodeIgniter Forums
DataMapper ORM v1.8.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: DataMapper ORM v1.8.0 (/showthread.php?tid=37531)



DataMapper ORM v1.8.0 - El Forum - 05-04-2011

[eluser]nomie7[/eluser]
Code:
$data['data'] = $user->get_by_id(1)->to->get();

Does not return information about the user from the user table. I set the relations like you mentioned above.


DataMapper ORM v1.8.0 - El Forum - 05-04-2011

[eluser]nomie7[/eluser]
In addition to above this code does bring the information needed but instead how can I get the messages by user instead of message id.
Code:
$data['data'] =$m->include_related('from')->include_related('to')->get_by_id(4);

Sorry if I am being pain in the #$#


------------

Edit: my mistake got it THANK YOU SO MUCH!


DataMapper ORM v1.8.0 - El Forum - 05-05-2011

[eluser]WanWizard[/eluser]
After you executed this, what is the result of $user->check_last_query() ?

You should be able to retrieve the messages by using
Code:
$user = new User();
$user->get_by_id(1);

// get all messages by from user
$user->from->get();

foreach($user->from as $message)
{
    echo $message->id, "<br />";
}



DataMapper ORM v1.8.0 - El Forum - 05-06-2011

[eluser]Anestetikas[/eluser]
Hi, im having some trouble with generating the right query.
I have a table with multiple last_name fields like:
id, name1, name2, name3, name4, name5
And when I insert or edit this table i explode input field by space " ". And its all good.

My first search used same principle:
Code:
case "last_name":
$person->like('name1', $name, 'after');
$person->or_like('name2', $name, 'after');
...
break;

This generates:
Code:
SELECT `persons`.`id`, `persons`.`birth_date`, `persons`.`birth_place`, concat_ws(' ',
    `persons`.`name1`, `persons`.`name2`, `persons`.`name3`, `persons`.`name4`,
    `persons`.`name5`) AS name, `personEvents`.`description` AS
    personevent_description
FROM (`persons`)
LEFT OUTER JOIN `personEvents` personEvents ON
    `personEvents`.`id` = `persons`.`personevent_id`
WHERE `persons`.`name1` LIKE 'jorda%'
OR
    `persons`.`name2` LIKE 'jorda%'
OR `persons`.`name3` LIKE 'jorda%'
OR `persons`.`name4`
    LIKE 'jorda%'
OR `persons`.`name5` LIKE 'jorda%'
ORDER BY `name` asc
LIMIT 500

And its all good if there is only one word in search input like "Jorda" for (Jordan). But i need to have a search that is capable of doing the folowing: If I input "jorda brow" for (Jordan Brown).

I tried to:
Code:
case "last_name":
   $names = explode(" ", $last_name);
   foreach ($names as $name){
      $person->like('name1', $name, 'after');
      $person->or_like('name2', $name, 'after');
      .....
   }
   break;
But it gives me:
Code:
SELECT `persons`.`id`, `persons`.`birth_date`, `persons`.`birth_place`, concat_ws(' ',
    `persons`.`name1`, `persons`.`name2`, `persons`.`name3`, `persons`.`name4`,
    `persons`.`name5`) AS name, `personEvents`.`description` AS
    personevent_description
FROM (`persons`)
LEFT OUTER JOIN `personEvents` personEvents ON
    `personEvents`.`id` = `persons`.`personevent_id`
WHERE `persons`.`name1` LIKE 'jorda%'
OR
    `persons`.`name2` LIKE 'jorda%'
OR `persons`.`name3` LIKE 'jorda%'
OR `persons`.`name4` LIKE
    'jorda%'
OR `persons`.`name5` LIKE 'jorda%'
AND `persons`.`name1` LIKE 'brow%'
OR
    `persons`.`name2` LIKE 'brow%'
OR `persons`.`name3` LIKE 'brow%'
OR `persons`.`name4` LIKE
    'brow%'
OR `persons`.`name5` LIKE 'brow%'
ORDER BY `name` asc
LIMIT 500

And I think I need it to be like:
Code:
SELECT `persons`.`id`, `persons`.`birth_date`, `persons`.`birth_place`, concat_ws(' ',
    `persons`.`name1`, `persons`.`name2`, `persons`.`name3`, `persons`.`name4`,
    `persons`.`name5`) AS name, `personEvents`.`description` AS
    personevent_description
FROM (`persons`)
LEFT OUTER JOIN `personEvents` personEvents ON
    `personEvents`.`id` = `persons`.`personevent_id`
WHERE (`persons`.`name1` LIKE 'jorda%'
OR
    `persons`.`name2` LIKE 'jorda%'
OR `persons`.`name3` LIKE 'jorda%'
OR `persons`.`name4` LIKE
    'jorda%'
OR `persons`.`name5` LIKE 'jorda%')
AND (`persons`.`name1` LIKE 'brow%'
OR
    `persons`.`name2` LIKE 'brow%'
OR `persons`.`name3` LIKE 'brow%'
OR `persons`.`name4` LIKE
    'brow%'
OR `persons`.`name5` LIKE 'brow%')
ORDER BY `name` asc
LIMIT 500


Please advice.

... Need to learn to read manuals $obj->group_start(); ftw!


DataMapper ORM v1.8.0 - El Forum - 05-08-2011

[eluser]AMR[/eluser]
Heya

Where can one post suggested fixes/changes/updates etc etc? Is there a repo anywhere?


Thanks


DataMapper ORM v1.8.0 - El Forum - 05-08-2011

[eluser]Basketcasesoftware[/eluser]
@AMR - You can do it in this forum. And if you look back at the beginning of this thread you see the link to Github for the app.


DataMapper ORM v1.8.0 - El Forum - 05-09-2011

[eluser]WanWizard[/eluser]
Correction: http://bitbucket.org/wanwizard/datamapper.

But it's best to discuss it here first, to make sure your case is valid.


DataMapper ORM v1.8.0 - El Forum - 05-09-2011

[eluser]Robert Liljedahl[/eluser]
Hi guys.

I'm using Datamapper+HMVC.

I'm trying to use

Code:
Datamapper::add_model_path()

from MY_Loader in order to get access to not loaded modules(/models).

However I am not allowed to do this:
Code:
PHP Fatal error:  Call to protected method DataMapper::add_model_path() from context 'MY_Loader' in /---/application/core/MY_Loader.php on line 21

What's the correct way of calling the function?


DataMapper ORM v1.8.0 - El Forum - 05-09-2011

[eluser]WanWizard[/eluser]
That's a bug in the current released version, which is fixed in develop.

Just open application/libraries/datamapper.php, find the add_model_path() method declaration, and change 'protected function' to 'public function'.


DataMapper ORM v1.8.0 - El Forum - 05-09-2011

[eluser]AMR[/eluser]
@Basketcasesoftware, @WanWizard Thanks guys

Would be good of Datamapper could easily be renamed; to say dm. In my case, I currently have 1.6 Datamapper in live production; but just wanted to run 1.8 side by side to test out some bits n bobs (mainly nested sets etc)

I found it hard because there are a lot of static references to 'DataMapper', for example the configuration files

Code:
DataMapper::$config

I eventually managed to go through and rename all the parts so that 1.8 was called DataMapperDMZ; but it was a pain.

Is there a bad reason for naming those static references based on the class name? Like how the class does at the start; to determine if $is_dmz?

Or setting a property at the beginning of the class?

Thanks