我決定結束與Doctrine 2.3的合作,現在我只想使用CodeIgniter建立數據庫連接,你知道我的代碼在哪裏嗎?CodeIgniter與數據庫的連接
此錯誤,我得到:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Hello::$db
Filename: core/Model.php
Line Number: 51
database.php中
$db['default']['hostname'] = 'localhost:8080';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'ci_doctrine';
$db['default']['dbdriver'] = 'mysql';
控制器
<?php
// system/application/controllers/hello.php
class Hello extends CI_Controller {
public function __construct()
{
parent::__construct();
}
function world() {
echo "Hello CodeIgniter!";
}
function user_test() {
$this->load->model('user');
$this->user->save_User('username','password','first_name','last_name');
}
}
?>
模式 - 在數據庫中「用戶」
<?php
// system/application/models/user.php
class User extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function save_User($username,$password,$fName,$lName) {
$this->username = $username;
$this->password = $password;
$this->first_name = $fName;
$this->last_name = $lName;
$this->db->insert('user', $this);
}
}
?>
你在本地?如果是,然後嘗試刪除8080後 –
@raheel山,但如果我將刪除此端口,我無法連接到網站。我的端口80有Skype和WAMP有8080. –