当前位置: 首页 > news >正文

web前端表单制作seo 页面链接优化

web前端表单制作,seo 页面链接优化,wordpress弹框,手机网站怎么建设一、实现功能,数据表前缀、alias、model、table、join方法实现 二、表前缀实现 1、config.php增加表前缀 DB_PEX>fa_,//数据库前缀 2、增加表前缀方法function.php function model($table){$modelnew ModelBase($table,config("DB_PEX"));return $m…

一、实现功能,数据表前缀、alias、model、table、join方法实现

 

 二、表前缀实现

1、config.php增加表前缀
 'DB_PEX'=>'fa_',//数据库前缀
 2、增加表前缀方法function.php
function model($table){$model=new  ModelBase($table,config("DB_PEX"));return $model;
}
function table($table){return  new  ModelBase($table);
}
3、PDO数据表增加表前缀ModelBase.php
    private $pex="";//表前缀public function __construct($table=null,$pex=""){$this->pex=$pex;if($table){$this->table=$this->pex.$table;}if(!$this->table){die("no table" );}$this->_connect();$this->_opt();}

三、alias数据表别名和join实现实现ModelBase.php

    private function _opt(){$this->opt=array('filed'=>'*','where'=>'','group'=>'','having'=>'','order'=>'','limit'=>'','alias'=>'','join'=>'',);}public function alias($as){$this->opt['alias']=  ' as '.$as." ";return $this;}public function join($join,$condition,$type=''){$this->opt['join']=  " {$type} join ".$this->pex.trim($join)." on {$condition}";return $this;}public function select(){$sql = "SELECT ".$this->opt['filed']. " FROM ".$this->table.$this->opt['alias'].$this->opt['join'].$this->opt['where'].$this->opt['group'].$this->opt['having'].$this->opt['order'].$this->opt['limit'];$stmt = $this->pdo->prepare($sql);$stmt->execute();return $stmt->fetchAll(PDO::FETCH_ASSOC);}

四、控制器实现,数据表前缀、alias、model、table、join方法查询

 public function index(){$data= model("test")->filed('t.*,r.role')->alias('t')->join('role r','t.id=r.testId','left')->select();var_dump($data);$data= table("fa_test")->select();var_dump($data);}

五、完整ModelBase.php代码

<?php
class ModelBase
{public $pdo = NULL;public $table = NULL;public $opt;private $pex="";//表前缀public function __construct($table=null,$pex=""){$this->pex=$pex;if($table){$this->table=$this->pex.$table;}if(!$this->table){die("no table" );}$this->_connect();$this->_opt();}private function _connect(){if($this->pdo){return true;}$host = config('DB_HOST');$db = config('DB_DATABASE');$user = config('DB_USER');$pass =config('DB_PWD');$dsn = "mysql:host=$host;dbname=$db;charset=utf8";try {$this->pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);} catch (PDOException $e) {die("数据库连接失败: " . $e->getMessage());}}private function _opt(){$this->opt=array('filed'=>'*','where'=>'','group'=>'','having'=>'','order'=>'','limit'=>'','alias'=>'','join'=>'',);}public function alias($as){$this->opt['alias']=  ' as '.$as." ";return $this;}public function join($join,$condition,$type=''){$this->opt['join']=  " {$type} join ".$this->pex.trim($join)." on {$condition}";return $this;}public function where($where){$this->opt['where']=  ' WHERE '.$where;return $this;}public function order($order){$this->opt['order']=  ' ORDER BY '.$order;return $this;}public function group($group){$this->opt['group']=  ' GROUP BY '.$group;return $this;}public function having($having){$this->opt['having']=  ' having '.$having;return $this;}public function filed($filed){$this->opt['filed']= $filed;return $this;}public function limit($limit){$this->opt['limit']=  ' limit '.$limit;return $this;}public function select(){$sql = "SELECT ".$this->opt['filed']. " FROM ".$this->table.$this->opt['alias'].$this->opt['join'].$this->opt['where'].$this->opt['group'].$this->opt['having'].$this->opt['order'].$this->opt['limit'];$stmt = $this->pdo->prepare($sql);$stmt->execute();return $stmt->fetchAll(PDO::FETCH_ASSOC);}public function find(){$data=$this->limit(1)->select();return current($data);}public function delete(){$sql = "DELETE FROM ".$this->table.$this->opt['where'];$stmt = $this->pdo->prepare($sql);$stmt->execute();return $stmt->rowCount();}public function insert( $data) {// 准备SQL语句$fields = implode(', ', array_keys($data));$values = ':' . implode(', :', array_keys($data));$sql = "INSERT INTO ". $this->table." (".$fields.") VALUES (".$values.")";// 绑定参数并执行SQL语句$stmt = $this->pdo->prepare($sql);foreach ($data as $key => $value) {$stmt->bindValue(':' . $key, $value);}return $stmt->execute();}public function update( $data){if(empty($this->opt['where'])) die('更新语句必须有were条件');$up='';foreach ($data as $k=>$v){$up.="`".$k."`='".$v."'";}$sql="update  ".$this->table.' set '.$up.$this->opt['where'];$stmt = $this->pdo->prepare($sql);$stmt->execute();return $stmt->rowCount();}}

http://www.hkea.cn/news/20719/

相关文章:

  • 装修公司全包项目seo搜索引擎实训心得体会
  • 爱站网是干什么的长沙关键词排名首页
  • wordpress 教垜四川seo推广公司
  • 东莞市阳光网青岛seo服务
  • 网站弹窗在中间位置企业培训师
  • 整站下载器 安卓版域名解析查询站长工具
  • 跨境自建站模板seo推广是做什么
  • 网站建设与网页设计报告网络营销师报名入口
  • 生成前端页面的网站东莞网络营销全网推广
  • 网站及单位网站建设情况免费男女打扑克的软件
  • 公司有网站有什么好处网上开店如何推广自己的网店
  • 海口网站建设策划关键词排名优化工具有用吗
  • 请问哪里可以做网站汕头seo
  • 访问国外网站速度慢苏州关键词seo排名
  • 做网站备案照片的要求谷歌seo教程
  • wordpress站点全屏新站如何让百度快速收录
  • wordpress 会议 主题推广排名seo
  • 源码开发网站建设sem与seo的区别
  • 如何查网站的空间防恶意点击软件
  • 单位网站建设收费标准互联网推广引流
  • 网站有中文源码加英文怎么做关键词歌词完整版
  • 建设网站企业银行做网站的平台
  • 如何进行网站建设分析网站推广app软件
  • 做ppt的软件模板下载网站网站服务公司
  • 网站icp备案认证怎么做谷歌网页版入口在线
  • 高安网站建设艺考培训
  • 主流的网站开发技术百度推广后台管理
  • 传奇网站模板免费下载优化网络搜索引擎
  • 提升学历报考什么专业比较好seosem顾问
  • 做违法网站犯法吗推广费用一般多少钱