Pfinal框架更新
本次更新点: 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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











A friend's computer has such a fault. When opening "This PC" and the C drive file, it will prompt "Explorer.EXE Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the project." Including folders, files, This computer, Recycle Bin, etc., double-clicking will pop up such a window, and right-clicking to open it is normal. This is caused by a system update. If you also encounter this situation, the editor below will teach you how to solve it. 1. Open the registry editor Win+R and enter regedit, or right-click the start menu to run and enter regedit; 2. Locate the registry "Computer\HKEY_CLASSES_ROOT\PackagedCom\ClassInd"

Windows updates may cause some of the following problems: 1. Compatibility issues: Some applications, drivers, or hardware devices may be incompatible with new Windows updates, causing them to not work properly or crash. 2. Performance issues: Sometimes, Windows updates may cause the system to become slower or experience performance degradation. This may be due to new features or improvements requiring more resources to run. 3. System stability issues: Some users reported that after installing Windows updates, the system may experience unexpected crashes or blue screen errors. 4. Data loss: In rare cases, Windows updates may cause data loss or file corruption. This is why before making any important updates, back up your

Evaluating the cost/performance of commercial support for a Java framework involves the following steps: Determine the required level of assurance and service level agreement (SLA) guarantees. The experience and expertise of the research support team. Consider additional services such as upgrades, troubleshooting, and performance optimization. Weigh business support costs against risk mitigation and increased efficiency.

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

Writing clear and comprehensive documentation is crucial for the Golang framework. Best practices include following an established documentation style, such as Google's Go Coding Style Guide. Use a clear organizational structure, including headings, subheadings, and lists, and provide navigation. Provides comprehensive and accurate information, including getting started guides, API references, and concepts. Use code examples to illustrate concepts and usage. Keep documentation updated, track changes and document new features. Provide support and community resources such as GitHub issues and forums. Create practical examples, such as API documentation.

Choose the best Go framework based on application scenarios: consider application type, language features, performance requirements, and ecosystem. Common Go frameworks: Gin (Web application), Echo (Web service), Fiber (high throughput), gorm (ORM), fasthttp (speed). Practical case: building REST API (Fiber) and interacting with the database (gorm). Choose a framework: choose fasthttp for key performance, Gin/Echo for flexible web applications, and gorm for database interaction.

Browser updates and upgrades are not uncommon, and some of the problems we encounter online may be caused by the system not being updated in time. Stable updates can ensure normal use of the browser, and we can better use the functions inside and maximize the performance of the browser. So how to update Google Chrome? This site brings you how to update Google Chrome to solve everyone's difficulties. The first step to update Google Chrome: Open the Chrome browser and click the [three dots] in the upper right corner. (As shown in the picture) Step 2: Click [Settings] in the menu drop-down to enter. (As shown in the picture) Step 3: Find [About Chrome] on the right and click to enter. (As shown in the picture) Step 4: Chrome browser will automatically check and install updates. (As shown in the picture
