很多站长朋友们都不太清楚phpinitdata,今天小编就来给大家整理phpinitdata,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 php 模拟数据怎么改成读取数据库? 2、 php有什么可靠的框架么 3、 php中怎么把数据库连接写成一个接口 4、 火车采集器使用PHP插件配置循环标签的方法 5、 PHP代码,能详细解释一下每行的意思么?多谢了 6、 ECmall本地怎么安装 wamp环境 把ECmall 放到www文件下 为什么 http://caicms.wengbi.com/install.index.php打不开 php 模拟数据怎么改成读取数据库?$query = "SELECT id,pid,name FROM tree ";
$tree_data=array();
if ($res=mysql_query($query)) while ($row=mysql_fetch_array($res)) $tree_data[]=$row;
php有什么可靠的框架么以下为十个目前最流行的基于MVC设计模式的PHP框架。
1. Yii
Yii是一个基于组件的高性能的PHP的框架,用于开发大规模Web应用。Yii采用严格的OOP编写,并有着完善的库引用以及全面的教程。从MVC,DAO/ActiveRecord,widgets,caching,等级式RBAC,Web服务,到主体化,I18N和L10N,Yii提供了今日Web 2.0应用开发所需要的几乎一切功能。而且这个框架的价格也并不太高。事实上,Yii是最有效率的PHP框架之一。
2. CodeIgniter
CodeIgniter是一个应用开发框架——一个为建立PHP网站的人们所设计的工具包。其目标在于快速的开发项目:它提供了丰富的库组以完成常见的任务,以及简单的界面,富有条理性的架构来访问这些库。使用CodeIgniter开发可以往项目中注入更多的创造力,因为它节省了大量编码的时间。
3. CakePHP
CakePHP是一个快速开发PHP的框架,其中使用了一些常见的设计模式如ActiveRecord,Association Data Mapping,Front Controller以及MVC。其主要目标在于提供一个令任意水平的PHP开发人员都能够快速开发web应用的框架,而且这个快速的实现并没有牺牲项目的弹性。
4. PHPDevShell
PHPDevShell是一个开源(GNU/LGPL)的快速应用开发框架,用于开发不含Javascript的纯PHP。它有一个完整的GUI管理员后台界面。其主要目标在于开发插件一类的基于管理的应用,其中速度、安全、稳定性及弹性是最优先考虑的重点。其设计形成了一个简单的学习曲线,PHP开发者无需学习复杂的新术语。PHPDevShell的到来满足了开发者们对于一个轻量级但是功能完善,可以无限制的进行配置的GUI的需求。
5. Akelos
Akelos PHP框架是一个基于MVC设计模式的web应用开发平台。基于良好的使用习惯,使用它可以完成如下任务:
◆方便的使用Ajax编写views
◆通过控制器管理请求(request)及响应(response)
◆管理国际化的应用
◆使用简单的协议与模型及数据库通信
你的Akelos应用可以在大多数共享主机服务供应方上运行,因为Akelos对服务器唯一的要求就是支持PHP。因此,Akelos PHP框架是理想的用于发布单独web应用的框架,因为它不需要非标准PHP配置便能运行。
6. Symfony
Symfony是一个用于开发PHP5项目的web应用框架。
这个框架的目的在于加速web应用的开发以及维护,减少重复的编码工作。
Symfony的系统需求不高,可以被轻易的安装在任意设置上:你只需一个Unix或Windows,搭配一个安装了PHP5的网络服务器即可。它与差不多所有的数据库兼容。Symfony的价位不高,相比主机上的花销要低得多。
对于PHP开发者而言,使用Symfony是一件很自然的事,其学习曲线只有短短一天。干净的设计以及代码可读性将缩短开发时间。开发者可以将敏捷开发的原理(如DRY,KISS或XP等)应用在其中,将重点放在应用逻辑层面上,而不用花费大量时间在编写没完没了的XML配置文件上。
Symfony旨在建立企业级的完善应用程序。也就是说,你拥有整个设置的控制权:从路径结构到外部库,几乎一切都可以自定义。为了符合企业的开发条例,Symfony还绑定了一些额外的工具,以便于项目的测试,调试以及归档。
7. Prado
PRADO团队由一些PRADO狂热者组成,这些成员开发并推动PRADO框架以及相关项目的进行。
PRADO的灵感起源于Apache Tapestry。从04年开始,PRADO成为SourceForge上的开源项目之一。这个项目目前进展到了3.x版本。
8. Zend
作为PHP艺术及精神的延伸,Zend框架的基础在于简单,面向对象的最佳方法,方便企业的许可协议,以及经过反复测试的快速代码库。Zend框架旨在建造更安全,更可靠的Web 2.0应用及web服务,并不断从前沿厂商(如Google,Amazon,Yahoo,Flickr,StrikeIron和ProgrammableWeb等)的API那里吸收精华。
9. ZooP
Zoop PHP框架,意为Zoop面向对象的PHP框架。
这是个稳定,可伸缩并可移植的框架。从诞生到现在的5年间,已经在不少产品开发中被使用。Zoop是一个快速,有效并干净的框架。它的伸缩性很好,你可以只安装你需要的功能。
对代码并不很熟悉的开发者也可以通过Zoop快速的开发安全的web应用。熟练的开发者则可以更加将Zoop的弹性利用到极致。
Zoop建议将display,logic以及数据层(MVC)分开使用。
Zoop由很多组件和项目集合而成,其中包括smarty和prototype AJAX框架,PEAR模块等。高效的核心组件提供了很多你原本需要自己编码来实现的功能。Zoop内置的纠错功能可以通过配置实现生产环境下的错误日志生成,这个错误日志提供了很多信息,可读性很高,可以更轻易的寻找并排除错误。
Zoop的一个特别之处在于其GuiControls,在PHP中是一个相当革新的想法。它提供了很多form widgets与验证完整的集合到一起,并形成了一个可以轻松打造个性化GuiControls的框架。
10. QPHP
QPHP,意为快速PHP,它是一个与ASP.NET类似的MVC框架。基本上它是这样一个情况:
◆整合了Java和C#的美感
◆除去了在其他PHP框架中使用的Perl形式的意义含糊的语言
◆大量基于OOP的概念
国内的thinkphp也很不错,使用框架可以避免重建底层函数等,加快开发速度。
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 = ''; //表名
private static $link; //数据库链接句柄
private $data = array(); //中间数据容器
private $condition = ''; //查询条件
private $fields = array(); //字段信息
private $sql = array(); //sql集合,调试用
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']);
}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 = 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).")";
}elseif(!empty($this->data['condition'])){
//'预留WHERE', 'order', 'group', 'limit' …………等条件关键词处理接口
$where = $where ? "WHERE {$where}" : "WHERE 1";
isset($this->data['condition']['where']) $where .= ' AND '.$this->data['condition']['where'];
isset($this->data['condition']['group']) $where .= ' GROUP BY '.$this->data['condition']['group'];
isset($this->data['condition']['order']) $where .= ' ORDER BY '.$this->data['condition']['order'];
isset($this->data['condition']['limit']) $where .= ' LIMIT '.$this->data['condition']['limit'];
}else{
$where = "WHERE {$where}";
}
$this->condition = $where;
return $this;
}
//插入数据
public function insert($data = array(), $replace = false) {
$fields = $this->implodefields($data);
$insert = $replace ? 'REPLACE' : 'INSERT';
$sql = "{$insert} INTO `{$this->db}`.`{$this->table}` (".implode(', ',$fields[1]).") values (".implode(', ',$fields[2]).")";
$this->query($sql);
return $this->getInsertId();
}
//更新数据
public function update($data = array() ,$where = '') {
$numargs = func_num_args();
if ($numargs == 1) {
$where = $data;
$data = array();
}
$fields = $this->implodefields($data);
$this->condition($where);
$sql = "UPDATE `{$this->db}`.`{$this->table}` SET ".implode(', ',$fields[0])." {$this->condition}";
$this->query($sql);
return $this->getAffectedRows();
}
//删除数据
public function delete($where = NULL) {
if(!is_array($where) strtolower(substr(trim($where), 0, 6)) == 'delete'){
$sql = $where;
}else{
$this->condition($where);
$sql = "DELETE FROM `{$this->db}`.`{$this->table}` {$this->condition}";
}
$this->query($sql);
return $this->getAffectedRows();
}
//查询数据
public function select($where = NULL, $fields = '*') {
if(!is_array($where) strtolower(substr(trim($where), 0, 6)) == 'select'){
$sql = $where;
}else{
$this->condition($where);
$sql = "SELECT {$fields} FROM `{$this->db}`.`{$this->table}` {$this->condition}";
}
return $this->fetch($this->query($sql));
}
//查询一条数据
public function getOne($where, $fields = '*') {
$data = $this->select($where, $fields = '*');
if($data) {
return $data[0];
}
return array();
}
//查询多条数据
public function getAll($where, $fields = '*') {
$data = $this->select($where, $fields = '*');
return $data;
}
//结果数量
public function getCount($where = '', $fields = '*') {
$this->condition($where);
$sql = "SELECT count({$fields}) as count FROM `{$this->db}`.`{$this->table}` {$this->condition}";
$data = $this->query($sql);
if($data){
return @mysql_result($data,0);
}
return 0;
}
//执行sql语句(flag为0返回mysql_query查询后的结果,为1返回lastid,其他返回影响行数,默认为2返回影响行数)
public function query($sql, $flag = '0', $type = '') {
if ($this->config['dbDebug']) {
$startime = $this->microtime_float();
}
//查询
if ($type == 'UNBUFFERED' function_exists('mysql_unbuffered_query')) {
$result = @mysql_unbuffered_query($sql, self::$link);
} else {
//exit($sql);
$result = @mysql_query($sql, self::$link);
}
//重试
if (in_array(mysql_errno(self::$link), array(2006,2013)) empty($result) $this->config['dbPconnect']==0 !defined('RETRY')) {
define('RETRY',true); @mysql_close(self::$link); sleep(2);
$this->connect();
$result = $this->query($sql);
}
if ($result === false) {
$this->errdie($sql);
}
if ($this->config['dbDebug']) {
$endtime = $this->microtime_float();
$this->sql[] = array($sql,$endtime-$startime);
}
//清空操作数据
$this->data = array();
return $flag == '0' ? $result : ($flag == '1' ? $this->getInsertId() : $this->getAffectedRows());
}
//返回结果$onlyone为true返回一条否则返回所有,$type有MYSQL_ASSOC,MYSQL_NUM,MYSQL_BOTH
public function fetch($result, $onlyone = false, $type = MYSQL_ASSOC) {
if($result){
if ($onlyone) {
$row = @mysql_fetch_array($result, $type);
return $row;
}else{
$rowsRs = array();
while($row=@mysql_fetch_array($result, $type)) {
$rowsRs[] = $row;
}
return $rowsRs;
}
}
return array();
}
//可以运行SELECT,SHOW,EXPLAIN 或 DESCRIBE 等返回一个资源标识符的语句得到返回结果数组
public function show($sql, $onlyone = false) {
return $this->fetch($this->query($sql), $onlyone);
}
// 使用call函数处理同类型函数
private function __call($name, $arguments) {
$callArr = array('on', 'where', 'order', 'between', 'group', 'limit');
if (in_array($name, $callArr)) {
$this->data['condition'][$name] = $arguments[0];
}else{
$this->errdie("function error: function {$name} is not in ($this->class) class exist");
}
return $this;
}
//返回最后一次插入ID
public function getInsertId() {
return @mysql_insert_id(self::$link);
}
//返回受影响行数
public function getAffectedRows() {
return @mysql_affected_rows(self::$link);
}
//获取错误信息
private function error() {
return ((self::$link) ? @mysql_error(self::$link) : @mysql_error());
}
//获取错误信息ID
private function errno() {
return ((self::$link) ? @mysql_errno(self::$link) : @mysql_errno());
}
//获取版本信息
function version() {
if(empty($this->version)) {
$this->version = mysql_get_server_info(self::$link);
}
return $this->version;
}
//打印错误信息
private function errdie($sql = '') {
if ($this->config['dbDebug']) {
die('</BR><B>MySQL ERROR</B></BR>
SQL:'.$sql.'</BR>
ERRNO:'.$this->errno().'</BR>
ERROR:'.$this->error().'</BR>');
}
die('DB ERROR!!!');
}
//获取时间微妙数
private function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
//析构函数
public function __destruct() {
echo '<hr>';
$this->config['dbDebug'] print_r($this->sql);
//unset($this->result);
//unset($this->condition);
//unset($this->data);
}
}
class user extends Model {
//public $db = 'qsf_mvc';
//public $table = 'user';
public $primaryKey = 'uid';
}
$userObj = new user();
//---------------------------------------插入数据方法一-----------------------------------------
//模拟ActiveRecord模式 插入数据
$userObj->username = 'hoho';
$userObj->passwd = '1478522';
$userObj->email = 'qsf.z11@163.com';
$userObj->sex = 1;
$userObj->desc = '清洁工';
$insetId = $userObj->insert();
if ($insetId > 0) {
echo "插入ID为:{$insetId}<BR>";
}
//---------------------------------------插入数据方法二-----------------------------------------
//直接数组做参数插入数据
$userArr = array(
'username' => 'hoho',
'passwd' => '1478522',
'email' => 'qsf.z2121ia@163.com',
'sex' => '1',
'desc' => '厨师',
);
$insetId = $userObj->insert($userArr);
if ($insetId > 0) {
echo "插入ID为:{$insetId}<BR>";
}
//---------------------------------------更新数据方法一----------------------------------------
$userObj->username = 'h111oho';
$userObj->passwd = '1478511122';
$userObj->email = 'qsf111ia@163.com';
$userObj->sex = 1;
$userObj->desc = '清洁工';
$affectedRows1 = $userObj->update(89);
if ($affectedRows1 > 0) {
echo "影响行数为:{$affectedRows1}<BR>";
}
//---------------------------------------更新数据方法二----------------------------------------
//更新记录(传递参数的方式和insert操作一样)
$userArr = array(
'username' => 'hohoho',
'passwd' => '1474rr4448522',
'email' => 'qsf.rrza@165.com',
'sex' => '0',
'desc' => '厨师qq',
);
$affectedRows = $userObj->update($userArr, $insetId);
if ($affectedRows > 0) {
echo "影响行数为:{$affectedRows}<BR>";
}
//----------------------------------------查询数据----------------------------------------------
$userRs0 = $userObj->select(8); //单个主键值
//print_r($userRs0);
$userRs1 = $userObj->select(array(1,5,8)); //多个主键值的数组
//print_r($userRs1);
$userRs2 = $userObj->select('select count(*) as count from user where uid > 20'); //直接完整sql语句
//print_r($userRs2);
$userRs3 = $userObj->select("`uid` > 0"); //where条件
//print_r($userRs3);
$userRs4 = $userObj->getOne("`uid` > 0"); //获取单条记录
//print_r($userRs4);
$usersRs5 = $userObj->getAll("`uid` > 0"); ////获取所有记录
//print_r($usersRs5);
$usersRs6 = $userObj->limit('0,10')->where('uid > 100')->order('uid DESC')->group('username')->select();
//print_r($usersRs6);
//----------------------------------------删除数据-----------------------------------------------
//删除操作传递参数的方式和select操作一样
$userObj->delete(60); //单个主键值
$userObj->delete(array(1,5,8)); //多个主键值的数组
$userObj->delete('delete from user where uid > 100'); //直接完整sql语句
$userObj->delete("`uid` > 100"); //where条件
$userObj->limit('5')->where('uid > 80')->delete();
//----------------------------------------特殊查询-----------------------------------------------
$userShowRs = $userObj->show('show create table user', true); //获取特殊查询的结果,第二个参数代表返回一条结果还是所有的结果
火车采集器使用PHP插件配置循环标签的方法*参数说明:
* LabelUrl - 当前采集的页面的Url地址
*$LabelCookie - 当前采集页面,服务器返回的Cookie信息。
根据以上参数可以推断,我们需要在$LabelArray['Html'] 中对原标签进行处理
例如(替换):
插件中:
if( LabelArray['PageType']=="Content")
{
LabelArray['Html']);
}
else if( JsonData[initDataObj][goods][skus] as specs = normalPrice = groupPrice = skuId = shuxing = "";
foreach ( spec) {
spec[spec_key].'</span><span>:'. shuxing = spe;
}
shuxing.'</span><span>单价:'. sku[groupPrice].'</span><span>skuId:'. LabelArray['Html']='<test>'. LabelArray['Html'];
}
遇到的坑:
测试时在else if( LabelArray['PageType']=="List")中处理
一个插件文件需要在对应的配置中选择才会执行,例如插件有请求处理,结果处理,但是火车头配置中至选了结果处理插件,则请求的部分不会执行
PHP代码,能详细解释一下每行的意思么?多谢了php中类操作有几个关键字,$this, self, static, parent
$this很好区别,就是实例化后的对象,所以不能在静态方法里调用
class testA{
public $name="name";
public static function test() {
//出错! static方法不能使用this
echo $this->name;
}
}
self, static, parent 都是静态调用,后跟 :: 如果是变量,要加$
class testA{
//属性也要定义成静态的,不然也是访问不了的
public static $name="name";
public $mobile="";
public static function test() {
//可以访问
echo static::$name;
//不可访问
echo static::$mobile
}
}
下面说一下三者区别
self 指代当前定义方法所在的类
static 后期静态绑定的类 ( 实际调用中是哪个类,就代表哪个类,不一定是方法定义所在的类 )
parent 这个也好区别,就是当前定义类的父类
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
static::who(); // 后期静态绑定从这里开始
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
B::test();
以上代码,输出 B
因为最后调用是从B 这个类调用的
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
self::who();
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
B::test();
以上代码,输出 A
因为调用who时指定了当前类,不管最终从哪里调用,都会调用到A里定义的方法
另外 ,这三个关键字可跟在new 后面,来实例化代表的类,就不用重复写类名,方便维护。
参考:php:后期静态绑定
学php可以多看看官方手册
下面我再简单解释下你发的代码。
你这个应该是thinkphp的model吧,init静态方法是model的初始化方法,是一个静态方法,主要用于勾子处理(事件绑定)。这个调用可以从thinkphp的model类中找到。
一般在定义方法时需要覆盖父类方法,都会调用一下 parent::method() 用于先执行父类的方法,除非特意屏蔽父类初始方法就不调用。
ECmall本地怎么安装 wamp环境 把ECmall 放到www文件下 为什么 http://caicms.wengbi.com/install.index.php打不开地址错了吧,应该是
一般步骤如下:
1.将 upload 目录下的所有文件上传到您的商城安装目录下
2.在浏览器地址栏输入您的网站目录/install/index.php,根据提示完成安装
3.为安全起见,安装完成后请删除 install 目录
4.如果您想安装测试数据,把 initdata 目录上传到商城安装目录下,在浏览器地址栏输入 您的网站目录/initdata/index.php,根据提示完成安装
5.为安全起见,安装完成后删除 initdata 目录
关于phpinitdata的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于包含phpinitdata的词条的详细内容...