Home > php教程 > PHP开发 > body text

windframework的数据操作探讨

WBOY
Release: 2016-06-07 17:23:31
Original
1397 people have browsed it

在原生态的php+mysql开发中,在对数据库操作前需要链接数据库,实例化一个数据操作句柄,然后我们就可以对数据进行查询、添加和删除等操作了。那么在windframework框架中是如何获取一个实际的数据库操作句柄呢?下面将围绕这个问题作一些简单的探讨。


一般来说,框架的数据操作由数据模型层来处理,前面的WindFramework框架的项目部署已对windframework的部署作过介绍,现在以windframework自带的blog为例,blog的用户模型类为UserService.php,负责对数据查询和添加等处理,以供控制器IndexController.php调用。打开\blog\service\UserService.php,看下面的代码片断:

/**      
     * 用户注册服务      
     *       
     *@param UserForm $userInfo      
     *@return boolean      
     */
    public function register($userInfo) {      
        $db = $this->
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!