<?php
/*数据对象映射模式:*/
class User{
public $id;
public $name;
public $db;
public function __construct($id){
$this->db = @mysql_connect("localhost","root","root");
mysql_select_db("hxrz");
$res = mysql_query("select * from test where id = '{$id}'");
$row = mysql_fetch_assoc($res);
$this->id = $row['id'];
$this->name = $row['name'];
}
}
?>
/*数据对象映射模式:*/
class User{
public $id;
public $name;
public $db;
public function __construct($id){
$this->db = @mysql_connect("localhost","root","root");
mysql_select_db("hxrz");
$res = mysql_query("select * from test where id = '{$id}'");
$row = mysql_fetch_assoc($res);
$this->id = $row['id'];
$this->name = $row['name'];
}
}
?>