php根据数据库生成接口 用php创建数据库

php读取数据库数据后 怎么给每一天数据做连接?echo $Record[0]."br";
这里输出的本来就是不同的数据 , 给他加上链接就好了
echo 'a href=https://www.04ip.com/post/page.php?id='+$Record[0]+''.$Record[0]."/abr";
这样可以传递不同的参数
php中怎么把数据库连接写成一个接口我自己封装的一个
?php
class AppConfig{
public static $dbParam = array(
'dbHost' = 'localhost',
'dbUser' = 'root',
'dbPassword' ='',
'dbName' = '数据库名',
'dbCharset' = 'utf8',
'dbPort' = 3306,
'dbPrefix' = 'test_',
'dbPconnect' = 0,
'dbDebug' = true,
);
}
class Model {
private$version = '';//mysql版本
private$config = array();//数据库配置数组
private$class;//当前类名
public$tablepre = 'ts_';//表前缀
public$db = '';//库名
public$table = '';//表名
privatestatic $link;//数据库链接句柄
private$data = https://www.04ip.com/post/array();//中间数据容器
private$condition= '';//查询条件
private$fields = array();//字段信息
private$sql = array();//sql集合php根据数据库生成接口 , 调试用
public$primaryKey = 'id';//表主键
//构造函数初始化
public function __construct($dbParam = array()) {
$this-config = (is_array($dbParam)!empty($dbParam)) ? $dbParam : AppConfig::$dbParam;
$this-connect();
$this-init();
}
//链接数据库
private function connect() {
if($this-config['dbPconnect']) {
self::$link = @mysql_pconnect($this-config['dbHost'], $this-config['dbUser'], $this-config['dbPassword']);
【php根据数据库生成接口 用php创建数据库】}else{
self::$link = @mysql_connect($this-config['dbHost'], $this-config['dbUser'], $this-config['dbPassword'], true);
}
mysql_errno(self::$link) != 0$this-errdie('Could not connect Mysql: ');
$this-db= !empty($this-db) ? $this-db : $this-config['dbName'];
$serverinfo = $this-version();
if ($serverinfo'4.1'$this-config['dbCharset']) {
mysql_query("SET character_set_connection=".$this-config['dbCharset'].",character_set_results=".$this-config['dbCharset'].",character_set_client=binary", self::$link);
}
if ($serverinfo'5.0') {
mysql_query("SET sql_mode=''", self::$link);
}
@mysql_select_db($this-db, self::$link) or $this-errdie('Cannot use database');
return self::$link;
}
//表基本信息初始化
protected function init() {
$this-class = get_class($this);
$this-table = !empty($this-table) ? $this-table : strtolower($this-class);
$this-table = $this-tablepre . $this-table;
return $this;
}
//设置属性值
public function __set($name, $value) {
//exit($value);
$this-data['fields'][$name] = $value;
}
//获取属性值
public function __get($name) {
if(isset($this-data['fields'][$name])) {
return($this-data['fields'][$name]);
}else {
return NULL;
}
}
//字段信息处理
private function implodefields($data) {
if (!is_array($data)) {
$data = https://www.04ip.com/post/array();
}
$this-fields = !empty($this-data['fields']) ? array_merge($this-data['fields'], $data) : $data;
foreach($this-fields as $key = $value) {
$fieldsNameValueStr[] = "`$key`='$value'";
$fieldsNameStr[] = "`$key`";
$fieldsValueStr[] = "'$value'";
}
return array($fieldsNameValueStr, $fieldsNameStr, $fieldsValueStr);
}
//条件判断组装
private function condition($where = NULL) {
if (is_numeric($where)) {
$where = "WHERE `{$this-primaryKey}`='{$where}' LIMIT 1";
}elseif (is_array($where)){
$where = "WHERE `{$this-primaryKey}` in (".implode(',',$where).")";

推荐阅读