I've just set up a simple PHP Code Igniter project on a Windows 7 box, IIS 7, Fast CGI, no modules.
when I load up database in one of the function of a Model class by doing such this->load->database()
the thread seem to stop on that particular line. None of the subsequent operations are done.
class Account_model extends Model {
var $userId = '';
var $userName = '';
var $requestToken = '';
var $accessToken = '';
var $enabled = false;
var $startOfDay;
var $endOfDay;
function Account_model() {
parent::Model();
}
function get($userId) {
$this->load->database();
$query = $this->db->get_where('accounts', array('userId' => $userId), 1, 0);
return $query->result();
}
function insert() {
$this->load->database();
// ** stop **
$this->db->insert('accounts', $this); //never gets to this
}
}
If I simply ommit that line altogether, I get a php exception undefined variable $db in model.
The caller controller:
class SignUp extends Controller {
function SignUp() {
parent::Controller();
}
function createUser() {
echo 'processing';
$this->load->model('Account_model');
$this->Account_model->userId = 'asd';
$this->Account_model->userName = 'test_user_pls_delete';
$this->Account_model->enabled = true;
$this->Account_model->startOfDay = time();
$this->Account_model->insert();
echo 'done'; // never gets to this
}
}
I've verified the database configuration is correct (host name, driver, etc), and able to connect to the database server from the machine using MySQL workbrench.
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "{omitted}";
$db['default']['username'] = "{omitted}";
$db['default']['password'] = "{omitted}";
$db['default']['database'] = "{omitted}";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
The database table name: accounts
- Id int(11) primary key auto_increment
- UserId varchar(255) utf8_general_ci
- userName varchar(255) utf8_general_ci
- requestToken varchar(255) utf8_general_ci
- AccessToken varchar(255) utf8_general_ci
- Enabled tinyint(1)
- startOfDay time
- endOfDay time
Any ideas on how to fix this?