日期:2014-05-17 浏览次数:20424 次
class ActiveRecord
{
public $table;
public $data;
public $obj;
public function __construct($table)
{
$this->table = $table;
$this->data = array();
$this->obj = '';
$this->connect();
}
public function connect()
{
$config = array_change_key_case(require("Conf/config.php"));
if ((!empty($config['db_host'])) && (!empty($config['db_user'])) && (!empty($config['db_name']))) {
$db_host = $config['db_host'];
$db_user = $config['db_user'];
$db_pwd = $config['db_pwd'];
$db_name = $config['db_name'];
$con = mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name, $con);
mysql_query("SET NAMES UTF8");
}
}
public function __set($name, $value)
{
$this->data[$name] = $value;
if(is_object($this->obj)) {
$this->obj->$name = $value;
}
}
public function __get($name)
{
if(is_object($this->obj)) {
return $this->obj->$name;
}
}
public function add()