ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

DataMapper 1.6.0

September 05, 2008 12:32pm

Subscribe [115]
  • #991 / Feb 26, 2010 9:51am

    Spir

    139 posts

    I had weird issue using Datamapper. If I do this :

    $myObject->where('id', $id)->get();
    I have not the same result as :
    $myObject->get_by_id($id)->get();

    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.

  • #992 / Feb 26, 2010 10:17am

    NachoF

    171 posts

    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…..

    @Spir,
    it should just be
    $myObject->get_by_id($id);

    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).

  • #993 / Feb 26, 2010 10:24am

    Spir

    139 posts

    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?

  • #994 / Feb 26, 2010 12:56pm

    OverZealous

    1030 posts

    @Spir
    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.  😊

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

  • #995 / Mar 05, 2010 2:54pm

    GregX999

    39 posts

    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.

    Thanks,
    Greg

  • #996 / Mar 05, 2010 3:31pm

    OverZealous

    1030 posts

    @GregX999

    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.

    Edit:
    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();
    $foo->pressitem->get();
  • #997 / Mar 05, 2010 3:36pm

    OverZealous

    1030 posts

    DOH

    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.

  • #998 / Mar 05, 2010 3:52pm

    GregX999

    39 posts

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

  • #999 / Jul 21, 2010 5:38pm

    patie

    19 posts

    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? 😊

  • #1000 / Dec 08, 2010 6:51am

    cladff

    7 posts

    Hi,

    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

    $arr_u=array();
    $u=new User()
    $u->where('activated',1)->get()
    foreach($u->all as $user)
       $arr_u[]=$u->id;
    
    $p=new Project();
    $p->where_in_related($u,'id',$arr_u)->where('session','2010-01')->get();

    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.

  • #1001 / Dec 08, 2010 1:38pm

    WanWizard

    4475 posts

    DMZ 1.6.0 is not supported anymore.  The latest official release is 1.7.1.
    If it works on one server, but not on another, it’s not a Datamapper problem.

    Either you missed something when you copied the code over, the code is not identical, you’re using non-standard CI or Datamapper code, or you have a problem with the PHP and/or database version.

    You can do

    $p->check_last_query();

    on both servers after the where_in query to see if there are differences in the queries generated, and try to debug it from there.

  • #1002 / Dec 15, 2010 8:47am

    cladff

    7 posts

    thanks for ur advice i’ll test it 😊
    where can i find datamapper 1.7.1 ?? i didn’t understood this part

  • #1003 / Dec 15, 2010 2:28pm

    WanWizard

    4475 posts

    See http://datamapper.exitecms.org/pages/download.html for all official releases, or http://bitbucket.org/wanwizard/datamapper/get/tip.zip for the current development version (which is going to be 1.8.0 in a week or so).

  • #1004 / Jan 16, 2011 5:00am

    juanin

    4 posts

    I’m trying Datamapper + Codeignite 2 and when I try to start the tutorial going to http://localhost/Codeingiter/index.php/examples I receive
    Fatal error: Class ‘Controller’ not found in C:\xampp\htdocs\Codeingiter\application\controllers\examples.php on line 13.

    At line 13 I see this parent::Controller();

    Where is the problem ? Compatibility with CI2 ?

    Thanks

  • #1005 / Jan 16, 2011 5:04am

    juanin

    4 posts

    Making this:

    class Examples extends CI_Controller {


    function __construct()
    {
    parent::__construct();
    $this->load->helper('url');

    $this->output->enable_profiler(TRUE);
    }/**
        * Constructor
        *
        * Initialize Examples.
        */
      /*function Examples()
      {
    parent::Controller();

    $this->load->helper('url');

    $this->output->enable_profiler(TRUE);
    }*/

    Solved the problem…probably CI2 changed something.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases