由于我是 php 新手,我不确定可能是什么问题:
类.ManageUsers.php
<?php
include_once('class.database.php');
class ManageUsers{
public $link;
function _construct(){
$db_connection = new dbConnection();
$this->link = $db_connection->connect();
return $this->link;
}
function registerUsers($username, $password, $ip_address, $time, $date){
$query = $this->link->prepare("INSERT INTO TESTUSERS(username, password, ip_address, reg_time, reg_date ) values (?,?,?,?,?)");
$values = array($username, $password, $ip_address, $time, $date);
$query->execute($values);
$counts = $query->rowCount();
return $counts;
}
}
$user = new ManageUsers();
echo $user->registerUsers('foo', 'foo','127.0.0.1','12:00','12-9-2013');
?>
类.database.php
<?php
class dbConnection{
protected $db_conn;
public $db_name ='applicationdb';
public $db_user = 'root';
public $db_password = '';
public $db_host = 'localhost';
function connect(){
$this->db_conn = new PDO("mysql: host=$this->db_host;dbname=$this->db_name",$this->db_user,$this->db_password);
return $this->db_conn;
}
}
?>