CodeIgniter Forums
DataMapper ORM (PULLING MY HAIR OUT !!) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: DataMapper ORM (PULLING MY HAIR OUT !!) (/showthread.php?tid=38765)



DataMapper ORM (PULLING MY HAIR OUT !!) - El Forum - 02-18-2011

[eluser]rawoke083[/eluser]
Hi Guys !
Trying to get Datamapper to work with codeignitor 2.0

this is my model

Code:
//file modles/country.php:----------------------------------------
<?php

class Country extends DataMapper {

    var $table = 'countries';
  //  var $has_many = array('provinces'); <-- leave this for now, just get basics up

    
    
    function __construct($id = NULL)
    {
        parent::__construct($id);
    }

}
?&gt;


Code:
// Controller: controllers/ccountry.php

&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class CCountry extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        echo "Before";
    
        $my_country = new Country();
    
        echo "after";
        
        
        
        
        
    }
}
--------------------------------------------------------------------------------------------------------

It doesn't print anything after "Before" no error msg just dies

here is my sql for "counties"
-------------------------
countries | CREATE TABLE `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`country_code` varchar(4) DEFAULT NULL,
`tel_prefix` varchar(2) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1


DataMapper ORM (PULLING MY HAIR OUT !!) - El Forum - 02-18-2011

[eluser]Basketcasesoftware[/eluser]
Are you loading your the CI database system and DataMapper? I had a problem like that myself not to long ago. I don't see you initializing them in your controller unless you are autoloading them.


DataMapper ORM (PULLING MY HAIR OUT !!) - El Forum - 02-18-2011

[eluser]rawoke083[/eluser]
Yes autoloading both database and datamapper ? should i not ?


DataMapper ORM (PULLING MY HAIR OUT !!) - El Forum - 02-18-2011

[eluser]Basketcasesoftware[/eluser]
[quote author="rawoke083" date="1298038150"]Yes autoloading both database and datamapper ? should i not ?[/quote]
It's recommended if you tend to use your database in most of your controllers, otherwise just load them up when you need them.

I'm just trying to exhaust possibilities with your problem. Let me look at the test code I was trying and see if I did anything different...


DataMapper ORM (PULLING MY HAIR OUT !!) - El Forum - 02-18-2011

[eluser]Basketcasesoftware[/eluser]
It's almost 3 am and I need sleep. If you don't figure it out on your own or someone else helps you with it, I'll look at it in the morning.


DataMapper ORM (PULLING MY HAIR OUT !!) - El Forum - 02-18-2011

[eluser]WanWizard[/eluser]
This falls in the category "I have an error, can you fix it?"

Before posting questions like this, enable error reporting and display errors in your php.ini, and tell us exactly what your error is.
Otherwise we can keep on guessing for the rest of our lives...