Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM (PULLING MY HAIR OUT !!)
#1

[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
#2

[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.
#3

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

[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...
#5

[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.
#6

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




Theme © iAndrew 2016 - Forum software by © MyBB