本次更新点: 1.添加了扩展机制,可以自定义扩展 通过提供一个{$extensionName}Context.php的类,在启动配置中将上述扩展添加到系统,则可以实现扩展功能 2.添加了RPC模块,Pfinal_Remoting_Curl,提供基于权重的RR轮训调用策略 3.PfinalModelAbstract中添加
本次更新点:
1. 添加了扩展机制,可以自定义扩展
通过提供一个{$extensionName}Context.php的类,在启动配置中将上述扩展添加到系统,则可以实现扩展功能
2. 添加了RPC模块,Pfinal_Remoting_Curl,提供基于权重的RR轮训调用策略
3. PfinalModelAbstract中添加了数据库分布式策略,默认提供了一个MasterSlave策略,方便读写分离,可自行实现分库 PFinal
<?php class CaptchaConfig extends Pfinal_Config_Base{ /* (non-PHPdoc) * @see Pfinal_Config_Base::configConstant() */ public function configConstant(Pfinal_Config_Constant $me) { // TODO Auto-generated method stub $me->setDevMode(Pfinal_Config_Constant::MODE_PRODUCT); } /* (non-PHPdoc) * @see Pfinal_Config_Base::configRoute() */ public function configRoute(Pfinal_Config_Route $me) { // TODO Auto-generated method stub } /* (non-PHPdoc) * @see Pfinal_Config_Base::configPlugin() */ public function configPlugin(Pfinal_Config_Plugin $me) { // TODO Auto-generated method stub $conf = array( 'master'=>array( array('host'=>'127.0.0.1','port'=>3306,'user'=>'root','database'=>'test','passwd'=>'121'), array('host'=>'127.0.0.1','port'=>3306,'user'=>'root','database'=>'test','passwd'=>'567'), ), 'slave'=>array( array('host'=>'127.0.0.1','port'=>3306,'user'=>'root','database'=>'test','passwd'=>'aaa'), array('host'=>'127.0.0.1','port'=>3306,'user'=>'root','database'=>'test','passwd'=>'bbb'), ), ); $dbTest = new Pfinal_Plugin_DbConnection(new Pfinal_Model_Proxy_MasterSlave($conf)); $active = new Pfinal_Plugin_ActiveRecord(); $active->add('test', $dbTest); $me->add($dbTest); $me->add($active); } /* (non-PHPdoc) * @see Pfinal_Config_Base::configExtension() */ public function configExtension(Pfinal_Config_Extension $me) { // TODO Auto-generated method stub $me->addExtension(LIB.DIRECTORY_SEPARATOR.'common'); } /* (non-PHPdoc) * @see Pfinal_Config_Base::configInterceptor() */ public function configInterceptor() { // TODO Auto-generated method stub } /* (non-PHPdoc) * @see Pfinal_Config_Base::configHandler() */ public function configHandler() { // TODO Auto-generated method stub } }
<?php class Pfinal_Model_Proxy_MasterSlave implements Pfinal_Model_Proxy_Strategy{ protected $masterAdapters; protected $slaveAdapters; protected $adapter; public function __construct($dbConf,$adapter = 'mysql'){ if (empty($dbConf)){ throw new Pfinal_Exception_Argument("invalid master/slave dbconf", -1); } $this->adapter = $adapter; if (isset($dbConf['master'])&&!empty($dbConf['master'])){ foreach ($dbConf['master'] as $conf){ $this->cacheConnection($conf,$this->masterAdapters); } } if (isset($dbConf['slave'])&&!empty($dbConf['slave'])){ foreach ($dbConf['slave'] as $conf){ $this->cacheConnection($conf,$this->slaveAdapters); } } } /* (non-PHPdoc) * @see Pfinal_Model_Proxy_Strategy::getAdapterProxy() */ public function getAdapterProxy(Pfinal_Model_Statement $stm) { // TODO Auto-generated method stub if ($stm instanceof Pfinal_Model_Selector){ shuffle($this->slaveAdapters); $adapter = end($this->slaveAdapters); } if ($stm instanceof Pfinal_Model_Update || $stm instanceof Pfinal_Model_Insert || $stm instanceof Pfinal_Model_DDL){ shuffle($this->masterAdapters); $adapter = end($this->masterAdapters); } return $adapter; } protected function cacheConnection($conf,&$pool){ if (!is_array($pool)){ $pool = array(); } $host = $conf['host']; $port = $conf['port']; $user = $conf['user']; $passwd = $conf['passwd']; $database = $conf['database']; $instance = null; switch ($this->adapter){ case 'mysql': default: $instance = new Pfinal_Model_Adapter_RMDBS(); $instance->init($conf); break; } if (null===$instance){ throw new Pfinal_Exception_Argument("unknow adaptername:{$this->adapter}", -1); } $key = md5(sprintf('%s:%s:%s:%s:%s',$host,$port,$user,$passwd,$database)); $pool[$key] = $instance; } }
<?php /** * permision模块 */ define ( 'EXTENSION_NAME', 'common' ); define ( 'VERSION', '1.0' ); define ( 'COMMON_DIR', dirname ( __FILE__ ) ); set_include_path ( get_include_path () . PATH_SEPARATOR . implode ( PATH_SEPARATOR, array ( COMMON_DIR ) ) ); class CommonContext implements Pfinal_Extension_Interface{ /* (non-PHPdoc) * @see Pfinal_Extension_Interface::bootstrap() */ public function bootstrap() { // TODO Auto-generated method stub } /* (non-PHPdoc) * @see Pfinal_Extension_Interface::autoload() */ public function autoload($classname) { // TODO Auto-generated method stub $dirs = array( COMMON_DIR.DIRECTORY_SEPARATOR.'util', COMMON_DIR.DIRECTORY_SEPARATOR.'interceptor', ); foreach ($dirs as $dir){ $file = $dir.DIRECTORY_SEPARATOR.$classname.'.php'; if (is_file($file)){ require_once $file; return true; } } return false; } }
<?php class Test_Model extends PfinalModelAbstract{ public function __construct($ormEnable){ $this->tableName = 'test'; $this->databaseName = 'test'; parent::__construct($ormEnable); } public function add(){ $this ->set('id', 3) ->set('name', StringUtil::MysqlEscapeString("adad'\\\n231'")) ->save(); } public function getXX($id){ return $this->findById($id); } }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
