本帖最后由 xjl756425616 于 2013-07-16 16:59:50 编辑
class ActiveRecord<br>{<br> public $table;<br> public $data;<br> public $obj; <br> public function __construct($table)<br> {<br> $this->table = $table;<br> $this->data = array(); <br> $this->obj = '';<br> $this->connect();<br> }<br> public function connect()<br> {<br> $config = array_change_key_case(require("Conf/config.php"));<br> if ((!empty($config['db_host'])) && (!empty($config['db_user'])) && (!empty($config['db_name']))) {<br> $db_host = $config['db_host'];<br> $db_user = $config['db_user'];<br> $db_pwd = $config['db_pwd'];<br> $db_name = $config['db_name'];<br> $con = mysql_connect($db_host, $db_user, $db_pwd);<br> mysql_select_db($db_name, $con);<br> mysql_query("SET NAMES UTF8");<br> }<br> }<br> public function __set($name, $value)<br> {<br> $this->data[$name] = $value;<br> if(is_object($this->obj)) {<br> $this->obj->$name = $value;<br> }<br> }<br> public function __get($name)<br> {<br> if(is_object($this->obj)) {<br> return $this->obj->$name;<br> }<br> }<br> public function add()<div class="clear">
</div>