• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DataMapper 1.6.0

I had weird issue using Datamapper. If I do this :
$myObject->where('id', $id)->get();
I have not the same result as :

Using the get_by_id method I have all the object even if ID exists. Using the where method I have the object I requested.

Any idea? I didn't take a closer look to those method within the lib yet.

When are people gonna understand that thing is not supported anymore?? the developer has been lost for years.... and new version of dmz datamapper was just released a couple of days ago and people still are stubborn enough to use this old thing.....

it should just be

but please switch to dmz.... what happened was that the creator of datamapper stopped working on it so Overzealous took over.. he decided to make it clear that it was his version by changing the name and now people think they are two different projects when in fact its just the new version of the same project (basically).

Yes actually I started using ORM in COdeIgniter this week with Datamapper. I saw DMZ was Datamapper upgraded and updated with new features and that to move from DM to DMZ is quite easy so I'll make the move for sure.

I see my mistake. Thanks.

By the way I was wondering what was better (I see DMZ use foreign key) : foreign key or new table with both key and an auto increment key when doing a relation.

I always have done foreign keys when 1..n and a third table when n..n
"Fifth normal form" looks old fashion style. Or am I wrong?

You are calling get() twice. If you look at the generated queries using CodeIgniter's output profiler, you would see this.

get-by_id DOES the get for you. That's the point. :-)

Oops, the responses wrapped to the next page. I see it's been answered already.

Forgive me if this has been answered already (the thread is SO long)...

How do you name model classes, model file names and database tables when the name has multiple words? For example, "Press Item". Do all three need to be named the same? Is one model class "PressItem" and db table "press_item"? And filename "press_item.php" or "pressitem.php"? The docs don't mention how that works.



File names, models, and database tables have to have the same name. They only differ in case (and pluralization for database tables). Naming is explained in DataMapper Models.

They must be valid PHP class names, which means no spaces, only alphanumerics and an underscore, and must start with a letter. (While databases allow table names with spaces, I highly recommend against that in general practice; DMZ does not allow it at all.)

The name of the table must simply be the lowercase pluralized form of the class name. Therefore PressItem becomes pressitems, while Press_Item becomes press_items. The filename is simply the lowercase form of the class name: pressitem.php or press_item.php, respectively.

(Technically, the classname should only have the first letter capitalized, but PHP is case-insensitive for class names, so don't worry about that.)

How you choose name multi-word items is up to you. I recommend using CamelCase and no underscores, as it makes debugging complex queries easier, since DMZ uses underscores to separate components when naming join tables and querying related tables.

I forgot to mention that the name of relationships to the item, unless specifically set, is the lowercase form of the class name (pressitem or press_item). IE:
$foo = new Foo();


I just realized which board I was on.

The above information should still be mostly correct, except the manual link takes you to DMZ's manual, not DataMapper's, and you cannot specifically name the relationship.

Sorry if there was any confusion.

Thanks, that's perfect! I didn't see there was a separate DMZ thread - I AM using the DMZ version.

datamapper is a cool thing! ... but the model (in MVC) has lost importance for me, most of the database command in the controller I have now is this normal? Smile


I have an issue with datamapper and 1and1.
In fact all works fine but when i try to make a where or other query _related it doesn't make link in query.

in exemple

$u=new User()
foreach($u->all as $user)

$p=new Project();

on my developpment server it works fine but on 1and1 it doesn't make anything about link between user and project in the query.

if you have an idea? i correct it for the moment with a hand crafted full query but i wanted to use datamapper fully...

Thanks in advance

Ps: Sorry about my english if there is mistakes.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.