<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>琪埃信息系统（上海）有限公司 &#187; zend framework 2</title>
	<atom:link href="http://www.qiais.com/achives/category/php/zf2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.qiais.com</link>
	<description>琪埃信息系统</description>
	<lastBuildDate>Tue, 11 Feb 2020 01:50:29 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0</generator>
	<item>
		<title>zend framework2 的transaction</title>
		<link>http://www.qiais.com/achives/622/</link>
		<comments>http://www.qiais.com/achives/622/#comments</comments>
		<pubDate>Mon, 17 Mar 2014 07:13:39 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=622</guid>
		<description><![CDATA[zend framework2 可以通过以下方式实现transaction。 ＊注＊：在别的地方，设置了名称为...]]></description>
				<content:encoded><![CDATA[<p>zend framework2 可以通过以下方式实现transaction。</p>
<p>＊注＊：在别的地方，设置了名称为valuation_objects的Session，此Session包含一个多维数组。<br />
$adapter的$this->config是通过ServiceManager处理的，也可以通过<a href="http://www.qiais.com/achives/483/" title="由浅入深详细剖析Zend Framework 2 数据库连接，获取数据" target="_blank">由浅入深详细剖析Zend Framework 2 数据库连接，获取数据</a>实现。</p>
<pre class="brush: plain; title: ; notranslate">
    public function saveObjectsAction() {
        $sessionObjects = new Container('valuation_objects');
        $objects = $sessionObjects-&gt;objects;
        $valuationId = $this-&gt;params()-&gt;fromRoute('id');
        $sessionObjects-&gt;objects = null;
        $adapter = new Adapter($this-&gt;config);
        $connection = null;
        try{
            //如果将下面这一行的注释去掉，数组编号为20的entity的id设置为null，将会执行数据写入操作的回滚处理，
            //$objects[20]['entity']['id'] = null;
            $connection = $adapter-&gt;getDriver()-&gt;getConnection();
            $connection-&gt;beginTransaction();
            foreach ($objects as $key =&gt; $object) {
                foreach($object['valuateUsers'] as $val)
                $adapter-&gt;query(
                    &quot;INSERT INTO valuation_objects(valuate_user_id, valuated_user_id, valuation_id) VALUES (?, ?, ?);&quot;,
                    array($object['entity']['id'], $val['id'], $valuationId)
                );
            }
            $connection-&gt;commit();
            $valuationTable = $this-&gt;getServiceLocator()-&gt;get('ValuationTable');
            $valuationTable-&gt;updateDecide($valuationId, 1);
        } catch (Exception $e) {
            if ($connection instanceof \Zend\Db\Adapter\Driver\ConnectionInterface) {
                $connection-&gt;rollback();
            }
        }
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/622/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework2 会员管理项目之五： 添加用户注册功能</title>
		<link>http://www.qiais.com/achives/610/</link>
		<comments>http://www.qiais.com/achives/610/#comments</comments>
		<pubDate>Sun, 16 Mar 2014 07:36:34 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=610</guid>
		<description><![CDATA[我们分以下步骤完成用户注册功能 1. 添加user模块，与zf2官方文档一样，添加User.php, User...]]></description>
				<content:encoded><![CDATA[<p>我们分以下步骤完成用户注册功能</p>
<p>1. 添加user模块，与zf2官方文档一样，添加<a href="http://www.qiais.com/achives/600/" title="Zend Framework2 会员管理项目之四： 用户列表分页功能" target="_blank">User.php</a>, UserTable.php</p>
<p>2. 添加user表单以及表单验证，RegisterForm.php与RegisterFilter.php</p>
<p>3. 在Module.php getServiceConfig函数注册上述表单</p>
<p>4. 在UserController.php中添加register函数实现注册</p>
<p>5. 添加register.phtml视图文件，完成注册界面</p>
<h3>在module/Member/src/Member/Model中添加User.php与UserTable.php</h3>
<p>User.php, 简单的类文件，<br />
exchangeArray()主要是将用户注册的数据（数组）转化为User的成员。<br />
setPassword()将密码加密，这里采用sha1方式，也可以用md5等加密方式。</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiai_Application
 * @package    Member
 * @subpackage Model
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Qiai-License http://www.qiai.com/licenses/qiai.ck.html
 * @link       http://www.qiais.com
 */

namespace Member\Model;

/**
 * User model
 *
 * @category   Gc_Application
 * @package    Member
 * @subpackage Model
 */
class User
{
    public $id;
    public $department_id;
    public $name;
    public $email;
    public $password;
    public $role;
    public $tel;
    public $fax;
    public $mobile;
    public $zipcode;
    public $address;
    public $created;

    /**
     * set password
     *
     * @param string $plain_password plain key
     *
     * @return void
     */
    public function setPassword($plain_password)
    {
        $this-&gt;password = sha1($plain_password);
    }

    /**
     * change form data to members of Member
     *
     * @param array $data form data
     *
     * @return void
     */
    function exchangeArray($data)
    {
        $this-&gt;id = (isset($data['id'])) ? $data['id'] : null;
        $this-&gt;department_id = (isset($data['department_id'])) ? $data['department_id'] : null;
        $this-&gt;name = (isset($data['name'])) ? $data['name'] : null;
        $this-&gt;email = (isset($data['email'])) ? $data['email'] : null;
        $this-&gt;role = (isset($data['role'])) ? $data['role'] : null;
        $this-&gt;tel = (isset($data['tel'])) ? $data['tel'] : null;
        $this-&gt;mobile = (isset($data['mobile'])) ? $data['mobile'] : null;
        $this-&gt;fax = (isset($data['fax'])) ? $data['fax'] : null;
        $this-&gt;zipcode = (isset($data['zipcode'])) ? $data['zipcode'] : null;
        $this-&gt;address = (isset($data['address'])) ? $data['address'] : null;
        $this-&gt;created = (isset($data['created'])) ? $data['created'] : null;

        if (isset($data[&quot;password&quot;])) {
            $this-&gt;setPassword($data[&quot;password&quot;]);
        }
    }

    /**
     * get object data
     *
     * @return array
     */
    public function getArrayCopy()
    {
        return get_object_vars($this);
    }
}

</pre>
<p>UserTable.php<br />
saveUser()函数将用户数据保存到数据库，判断是否有id，没有的话为新注册，有的话为更新。</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiai_Application
 * @package    Member
 * @subpackage Model
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Qiai-License http://www.qiai.com/licenses/qiai.ck.html
 * @link       http://www.qiais.com
 */

namespace Member\Model;

use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Paginator\Paginator;

/**
 * Member: TableGateway
 *
 * @category   Gc_Application
 * @package    Member
 * @subpackage Model
 */
class UserTable
{
    /**
    * TableGateway
    */
    protected $tableGateway;

    /**
     * __construct
     *
     * @param TableGateway $tableGateway TableGateway
     *
     * @return void
     */
    public function __construct(TableGateway $tableGateway)
    {
        $this-&gt;tableGateway = $tableGateway;
    }

    /**
     * fetchAll: get all data from table member.
     *
     * @return ResultSet
     */
    public function fetchAll($paginated=false)
    {
        if ($paginated) {
             // create a new Select object for the table album
             $select = new Select('users');
             // create a new result set based on the Album entity
             $resultSetPrototype = new ResultSet();
             $resultSetPrototype-&gt;setArrayObjectPrototype(new User());
             // create a new pagination adapter object
             $paginatorAdapter = new DbSelect(
                 // our configured select object
                 $select,
                 // the adapter to run it against
                 $this-&gt;tableGateway-&gt;getAdapter(),
                 // the result set to hydrate
                 $resultSetPrototype
             );
             $paginator = new Paginator($paginatorAdapter);
             return $paginator;
        }
        $resultSet = $this-&gt;tableGateway-&gt;select();
        return $resultSet;
    }

    /**
     * saveMember: save data for user.
     *
     * @param Member $user user object
     *
     * @return ResultSet
     */
    public function saveUser(User $user)
    {
        $nowtime = date(&quot;Y-m-d H:i:s&quot;);
        $data = array(
            'email' =&gt; $user-&gt;email,
            'name'  =&gt; $user-&gt;name,
            'role'  =&gt; $user-&gt;role,
            'password'  =&gt; $user-&gt;password,
            'tel'  =&gt; $user-&gt;tel,
            'mobile'  =&gt; $user-&gt;mobile,
            'fax'  =&gt; $user-&gt;fax,
            'zipcode'  =&gt; $user-&gt;zipcode,
            'address'  =&gt; $user-&gt;address,
            'modified' =&gt; $nowtime
        );

        $id = (int)$user-&gt;id;
        if ($id == 0) {
            $data['created'] = $nowtime;
            $this-&gt;tableGateway-&gt;insert($data);
        } else {
            if ($this-&gt;getUser($id)) {
                if(empty($data['password']))
                    unset($data['password']);
                $this-&gt;tableGateway-&gt;update($data, array('id' =&gt; $id));
            } else {
                throw new \Exception('User ID does not exist');
            }
        }
    }

    /**
     * Get User account by user id
     *
     * @param string $id string
     *
     * @throws \Exception
     * @return Row
     */
    public function getUser($id)
    {
        $id  = (int) $id;
        $rowset = $this-&gt;tableGateway-&gt;select(array('id' =&gt; $id));
        $row = $rowset-&gt;current();
        if (!$row) {
            throw new \Exception(&quot;Could not find row $id&quot;);
        }
        return $row;
    }

    /**
     * deleteMember: delete user.
     *
     * @param int $id user id
     *
     * @return void
     */
    public function deleteUser($id)
    {
        $this-&gt;tableGateway-&gt;delete(array('id' =&gt; $id));
    }

    /**
     * getUserByEmail: get user by email.
     *
     * @param string $email email address
     *
     * @return Object
     */
    public function getUserByEmail($email)
    {
        $rowset = $this-&gt;tableGateway-&gt;select(array('email' =&gt; $email));
        $row = $rowset-&gt;current();
        if (!$row) {
            throw new \Exception(&quot;Could not find row $email&quot;);
        }
        return $row;
    }
}
</pre>
<p>待续&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/610/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework2 会员管理项目之四： 用户列表分页功能</title>
		<link>http://www.qiais.com/achives/600/</link>
		<comments>http://www.qiais.com/achives/600/#comments</comments>
		<pubDate>Sun, 09 Mar 2014 10:54:20 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=600</guid>
		<description><![CDATA[zend framework 2 的分页功能变得很简单又方便！这里介绍会员管理项目的分页显示功能。界面如下： ...]]></description>
				<content:encoded><![CDATA[<p>zend framework 2 的分页功能变得很简单又方便！这里介绍会员管理项目的分页显示功能。界面如下：</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-09-02.png"><img src="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-09-02-600x368.png" alt="2014-03-09-02" width="600" height="368" class="alignnone size-medium wp-image-608" /></a></p>
<h3>步骤一：修改module/Member/src/Member/Model/UserTable.php</h3>
<pre class="brush: plain; title: ; notranslate">
    public function fetchAll($paginated=false)
    {
        if ($paginated) {
             $select = new Select('users');
             $resultSetPrototype = new ResultSet();
             $resultSetPrototype-&gt;setArrayObjectPrototype(new User());
             $paginatorAdapter = new DbSelect(
                 $select,
                 $this-&gt;tableGateway-&gt;getAdapter(),
                 $resultSetPrototype
             );
             $paginator = new Paginator($paginatorAdapter);
             return $paginator;
        }
        $resultSet = $this-&gt;tableGateway-&gt;select();
        return $resultSet;
    }
</pre>
<p>这里我们先创建了一个Select实例，select实例的limit与where会控制我们每页需要显示的数量及条件，然后创建DbSelect分页适配器去自动加载此实例。返回的结果与我们不使用分页时一样，都是User的实例列表。</p>
<h3>步骤二：修改module/Member/src/Member/Controller/UserController.php</h3>
<pre class="brush: plain; title: ; notranslate">
    public function indexAction()
    {
        // for pagination
        $userTable = $this-&gt;getServiceLocator()-&gt;get('UserTable');
        $paginator = $userTable-&gt;fetchAll(true);
        // set the current page to what has been passed in query string, or to 1 if none set
        $paginator-&gt;setCurrentPageNumber((int) $this-&gt;params()-&gt;fromQuery('page', 1));
        // set the number of items per page to 10
        $paginator-&gt;setItemCountPerPage(10);

        return new ViewModel(array(
            'paginator' =&gt; $paginator
        ));

        // for no pagination
        //$userTable = $this-&gt;getServiceLocator()-&gt;get('UserTable');
        //$viewModel  = new ViewModel(array('users' =&gt; $userTable-&gt;fetchAll()));
        //return $viewModel;
    }
</pre>
<h3>步骤三：更新module/Member/view/member/user/index.phtml</h3>
<pre class="brush: plain; title: ; notranslate">
&lt;h3&gt;Users&lt;/h3&gt;
&lt;table class=&quot;table table-bordered table-striped&quot;&gt;
&lt;tr&gt;
    &lt;th&gt;Name&lt;/th&gt;
    &lt;th&gt;Email&lt;/th&gt;
    &lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;?php
    /*foreach ($users as $user) : */
    foreach ($paginator as $user) :
?&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;?php echo $this-&gt;escapeHtml($user-&gt;name);?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $this-&gt;escapeHtml($user-&gt;email);?&gt;&lt;/td&gt;
    &lt;td&gt;
        &lt;a href=&quot;&lt;?php echo $this-&gt;url('member/user',
            array('action'=&gt;'edit', 'id' =&gt; $user-&gt;id));?&gt;&quot;&gt;Edit&lt;/a&gt; |
        &lt;a href=&quot;&lt;?php echo $this-&gt;url('member/user',
            array('action'=&gt;'delete', 'id' =&gt; $user-&gt;id));?&gt;&quot; onclick=&quot;return confirm('Are you sure?')&quot;&gt;Delete&lt;/a&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;?php endforeach; ?&gt;
&lt;/table&gt;
 &lt;?php
 echo $this-&gt;paginationControl(
     $this-&gt;paginator,
     'sliding',
     array('partials/paginator.phtml', 'User'),
     array('route' =&gt; 'member/user')
 );
 ?&gt;
&lt;hr /&gt;
</pre>
<h3>步骤四：创建分页功能的部件</h3>
<p>在module/Application/view下新建partials文件夹，然后在partials里面创建paginator.phtml文件，内容如下：</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php if ($this-&gt;pageCount): ?&gt;
 &lt;div&gt;
     &lt;ul class=&quot;pagination&quot;&gt;
         &lt;!-- Previous page link --&gt;
         &lt;?php if (isset($this-&gt;previous)): ?&gt;
             &lt;li&gt;
                 &lt;a href=&quot;&lt;?php echo $this-&gt;url($this-&gt;route); ?&gt;?page=&lt;?php echo $this-&gt;previous; ?&gt;&quot;&gt;
                     &lt;&lt;
                 &lt;/a&gt;
             &lt;/li&gt;
         &lt;?php else: ?&gt;
             &lt;li class=&quot;disabled&quot;&gt;
                 &lt;a href=&quot;#&quot;&gt;
                     &lt;&lt;
                 &lt;/a&gt;
             &lt;/li&gt;
         &lt;?php endif; ?&gt;

         &lt;!-- Numbered page links --&gt;
         &lt;?php foreach ($this-&gt;pagesInRange as $page): ?&gt;
             &lt;?php if ($page != $this-&gt;current): ?&gt;
                 &lt;li&gt;
                     &lt;a href=&quot;&lt;?php echo $this-&gt;url($this-&gt;route);?&gt;?page=&lt;?php echo $page; ?&gt;&quot;&gt;
                         &lt;?php echo $page; ?&gt;
                     &lt;/a&gt;
                 &lt;/li&gt;
             &lt;?php else: ?&gt;
                 &lt;li class=&quot;active&quot;&gt;
                     &lt;a href=&quot;#&quot;&gt;&lt;?php echo $page; ?&gt;&lt;/a&gt;
                 &lt;/li&gt;
             &lt;?php endif; ?&gt;
         &lt;?php endforeach; ?&gt;

         &lt;!-- Next page link --&gt;
         &lt;?php if (isset($this-&gt;next)): ?&gt;
             &lt;li&gt;
                 &lt;a href=&quot;&lt;?php echo $this-&gt;url($this-&gt;route); ?&gt;?page=&lt;?php echo $this-&gt;next; ?&gt;&quot;&gt;
                     &gt;&gt;
                 &lt;/a&gt;
             &lt;/li&gt;
         &lt;?php else: ?&gt;
             &lt;li class=&quot;disabled&quot;&gt;
                 &lt;a href=&quot;#&quot;&gt;
                     &gt;&gt;
                 &lt;/a&gt;
             &lt;/li&gt;
         &lt;?php endif; ?&gt;
     &lt;/ul&gt;
 &lt;/div&gt;
&lt;?php endif; ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/600/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework2 会员管理项目之三： 建立数据模型及显示用户列表</title>
		<link>http://www.qiais.com/achives/577/</link>
		<comments>http://www.qiais.com/achives/577/#comments</comments>
		<pubDate>Wed, 05 Mar 2014 00:06:09 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=577</guid>
		<description><![CDATA[这篇博客主要通过zf完成用户一览显示的功能 编辑 module/Member/src/Member/Model...]]></description>
				<content:encoded><![CDATA[<p>这篇博客主要通过zf完成用户一览显示的功能</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-05-01.png"><img src="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-05-01-581x600.png" alt="2014-03-05-01" width="581" height="600" class="alignnone size-medium wp-image-582" /></a></p>
<h3>编辑 module/Member/src/Member/Model/User.php文件</h3>
<p>这就是数据库表users的模型类文件，exchangeArray函数将表单传过来的用户信息数据转变为user的成员数据。</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiai_Application
 * @package    Member
 * @subpackage Model
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Qiai-License http://www.qiai.com/licenses/qiai.ck.html
 * @link       http://www.qiais.com
 */

namespace Member\Model;

/**
 * User model
 *
 * @category   Gc_Application
 * @package    Member
 * @subpackage Model
 */
class User
{
    public $id;
    public $name;
    public $email;
    public $password;
    public $role;
    public $tel;
    public $fax;
    public $mobile;
    public $zipcode;
    public $address;
    public $created;

    /**
     * set password
     *
     * @param string $plain_password plain key
     *
     * @return void
     */
    public function setPassword($plain_password)
    {
        $this-&gt;password = sha1($plain_password);
    }

    /**
     * change form data to members of Member
     *
     * @param array $data form data
     *
     * @return void
     */
    function exchangeArray($data)
    {
        $this-&gt;id = (isset($data['id'])) ? $data['id'] : null;
        $this-&gt;name = (isset($data['name'])) ? $data['name'] : null;
        $this-&gt;email = (isset($data['email'])) ? $data['email'] : null;
        $this-&gt;role = (isset($data['role'])) ? $data['role'] : null;
        $this-&gt;tel = (isset($data['tel'])) ? $data['tel'] : null;
        $this-&gt;mobile = (isset($data['mobile'])) ? $data['mobile'] : null;
        $this-&gt;fax = (isset($data['fax'])) ? $data['fax'] : null;
        $this-&gt;zipcode = (isset($data['zipcode'])) ? $data['zipcode'] : null;
        $this-&gt;address = (isset($data['address'])) ? $data['address'] : null;
        $this-&gt;created = (isset($data['created'])) ? $data['created'] : null;

        if (isset($data[&quot;password&quot;])) {
            $this-&gt;setPassword($data[&quot;password&quot;]);
        }
    }

    /**
     * get object data
     *
     * @return array
     */
    public function getArrayCopy()
    {
        return get_object_vars($this);
    }
}
</pre>
<h3> 编辑module/Member/src/Member/Model/UserTable.php文件</h3>
<p>UserTable类完成对users数据表的读取，写入等操作的封装。</p>
<p>public function fetchAll($paginated=false)<br />
函数有个$paginated参数，设为true的时候，将进行分页显示操作，这里暂时设置为false，以后要用到。</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiai_Application
 * @package    Member
 * @subpackage Model
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Qiai-License http://www.qiai.com/licenses/qiai.ck.html
 * @link       http://www.qiais.com
 */

namespace Member\Model;

use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Paginator\Paginator;

/**
 * Member: TableGateway
 *
 * @category   Gc_Application
 * @package    Member
 * @subpackage Model
 */
class UserTable
{
    /**
    * TableGateway
    */
    protected $tableGateway;

    /**
     * __construct
     *
     * @param TableGateway $tableGateway TableGateway
     *
     * @return void
     */
    public function __construct(TableGateway $tableGateway)
    {
        $this-&gt;tableGateway = $tableGateway;
    }

    /**
     * fetchAll: get all data from table member.
     *
     * @return ResultSet
     */
    public function fetchAll($paginated=false)
    {
        $resultSet = $this-&gt;tableGateway-&gt;select();
        return $resultSet;
    }

    /**
     * saveMember: save data for user.
     *
     * @param Member $user user object
     *
     * @return ResultSet
     */
    public function saveUser(User $user)
    {
        $nowtime = date(&quot;Y-m-d H:i:s&quot;);
        $data = array(
            'email' =&gt; $user-&gt;email,
            'name'  =&gt; $user-&gt;name,
            'role'  =&gt; $user-&gt;role,
            'password'  =&gt; $user-&gt;password,
            'tel'  =&gt; $user-&gt;tel,
            'mobile'  =&gt; $user-&gt;mobile,
            'fax'  =&gt; $user-&gt;fax,
            'zipcode'  =&gt; $user-&gt;zipcode,
            'address'  =&gt; $user-&gt;address,
            'modified' =&gt; $nowtime
        );

        $id = (int)$user-&gt;id;
        if ($id == 0) {
            $data['created'] = $nowtime;
            $this-&gt;tableGateway-&gt;insert($data);
        } else {
            if ($this-&gt;getUser($id)) {
                if(empty($data['password']))
                    unset($data['password']);
                $this-&gt;tableGateway-&gt;update($data, array('id' =&gt; $id));
            } else {
                throw new \Exception('User ID does not exist');
            }
        }
    }

    /**
     * Get User account by user id
     *
     * @param string $id string
     *
     * @throws \Exception
     * @return Row
     */
    public function getUser($id)
    {
        $id  = (int) $id;
        $rowset = $this-&gt;tableGateway-&gt;select(array('id' =&gt; $id));
        $row = $rowset-&gt;current();
        if (!$row) {
            throw new \Exception(&quot;Could not find row $id&quot;);
        }
        return $row;
    }

    /**
     * deleteMember: delete user.
     *
     * @param int $id user id
     *
     * @return void
     */
    public function deleteUser($id)
    {
        $this-&gt;tableGateway-&gt;delete(array('id' =&gt; $id));
    }

    /**
     * getUserByEmail: get user by email.
     *
     * @param string $email email address
     *
     * @return Object
     */
    public function getUserByEmail($email)
    {
        $rowset = $this-&gt;tableGateway-&gt;select(array('email' =&gt; $email));
        $row = $rowset-&gt;current();
        if (!$row) {
            throw new \Exception(&quot;Could not find row $email&quot;);
        }
        return $row;
    }
}
</pre>
<h3>编辑module/Member/src/Member/Module.php文件</h3>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiai_Application
 * @package    Member
 * @subpackage Module
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Qiai-License http://www.qiai.com/licenses/qiai.ck.html
 * @link       http://www.qiais.com
 */
namespace Member;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Member\Model\User;
use Member\Model\UserTable;

class Module implements AutoloaderProviderInterface
{
    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' =&gt; array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' =&gt; array(
                'namespaces' =&gt; array(
                    __NAMESPACE__ =&gt; __DIR__ . '/src/' . str_replace('\\', '/' , __NAMESPACE__),
                ),
            ),
        );
    }

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function onBootstrap(MvcEvent $e)
    {
        $eventManager        = $e-&gt;getApplication()-&gt;getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener-&gt;attach($eventManager);
    }

    /**
     * get services
     *
     * @return array
     */
    public function getServiceConfig()
    {
        return array(
            'abstract_factories' =&gt; array(),
            'aliases' =&gt; array(),
            'factories' =&gt; array(
                // DB
                'UserTable' =&gt;  function ($sm) {
                    $tableGateway = $sm-&gt;get('UserTableGateway');
                    $table = new UserTable($tableGateway);
                    return $table;
                },
                'UserTableGateway' =&gt; function ($sm) {
                    $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype-&gt;setArrayObjectPrototype(new User());
                    return new TableGateway('users', $dbAdapter, null, $resultSetPrototype);
                },
            ),
            'invokables' =&gt; array(),
            'services' =&gt; array(),
            'shared' =&gt; array(),
        );
    }
}
</pre>
<p>这里我们现在主要用到以下代码<br />
            &#8216;factories&#8217; => array(<br />
                // DB<br />
                &#8216;UserTable&#8217; =>  function ($sm) {<br />
                    $tableGateway = $sm->get(&#8216;UserTableGateway&#8217;);<br />
                    $table = new UserTable($tableGateway);<br />
                    return $table;<br />
                },<br />
                &#8216;UserTableGateway&#8217; => function ($sm) {<br />
                    $dbAdapter = $sm->get(&#8216;Zend\Db\Adapter\Adapter&#8217;);<br />
                    $resultSetPrototype = new ResultSet();<br />
                    $resultSetPrototype->setArrayObjectPrototype(new User());<br />
                    return new TableGateway(&#8216;users&#8217;, $dbAdapter, null, $resultSetPrototype);<br />
                },</p>
<p>通过zf2的ServiceManager连接数据库，获取容器，以便对users数据表操作。</p>
<h3> 编辑module/Member/src/Member/Controller/UserController.php文件</h3>
<p>添加indexAction函数，读取所有用户</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonModule for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Member\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Member\Model\User;
use Qiais\Auth;

class UserController extends AbstractActionController
{
    /**
     * index action
     *
     * @return array
     */
    public function indexAction()
    {
        // for no pagination
        $userTable = $this-&gt;getServiceLocator()-&gt;get('UserTable');
        $viewModel  = new ViewModel(array('users' =&gt; $userTable-&gt;fetchAll()));
        return $viewModel;
    }    
}
</pre>
<p>通过上面的代码，我们看到，zf2的ServiceManager让我们的代码变得非常简洁。读取所有用户数据只用了2行代码。</p>
<h3> 编辑module/Member/view/member/user/index.phtml文件</h3>
<p>这是UserController的indexAction的默认视图view文件</p>
<pre class="brush: plain; title: ; notranslate">
&lt;h3&gt;Users&lt;/h3&gt;
&lt;table class=&quot;table table-bordered table-striped&quot;&gt;
&lt;tr&gt;
    &lt;th&gt;Name&lt;/th&gt;
    &lt;th&gt;Email&lt;/th&gt;
    &lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;?php
    foreach ($users as $user) :
?&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;?php echo $this-&gt;escapeHtml($user-&gt;name);?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $this-&gt;escapeHtml($user-&gt;email);?&gt;&lt;/td&gt;
    &lt;td&gt;
        &lt;a href=&quot;&lt;?php echo $this-&gt;url('member/user',
            array('action'=&gt;'edit', 'id' =&gt; $user-&gt;id));?&gt;&quot;&gt;Edit&lt;/a&gt; |
        &lt;a href=&quot;&lt;?php echo $this-&gt;url('member/user',
            array('action'=&gt;'delete', 'id' =&gt; $user-&gt;id));?&gt;&quot; onclick=&quot;return confirm('Are you sure?')&quot;&gt;Delete&lt;/a&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;?php endforeach; ?&gt;
&lt;/table&gt;
&lt;hr /&gt;
&lt;a class=&quot;btn btn-primary&quot; href=&quot;&lt;?php echo $this-&gt;url('member/user',array('action'=&gt;'create'));?&gt;&quot;&gt;Add User&lt;/a&gt;
</pre>
<h3> 访问http://zf2.tutorial/member/users/index</h3>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-05-01.png"><img src="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-05-01-581x600.png" alt="2014-03-05-01" width="581" height="600" class="alignnone size-medium wp-image-582" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/577/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework2 会员管理项目之二：创建会员模块以及模块配置</title>
		<link>http://www.qiais.com/achives/540/</link>
		<comments>http://www.qiais.com/achives/540/#comments</comments>
		<pubDate>Sun, 02 Mar 2014 01:28:53 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=540</guid>
		<description><![CDATA[zf2的特点之一处就是模块化，这很便于我们团队协作，项目组成员可以在单独完成自己的模块，然后整合。 创建Mem...]]></description>
				<content:encoded><![CDATA[<p>zf2的特点之一处就是模块化，这很便于我们团队协作，项目组成员可以在单独完成自己的模块，然后整合。</p>
<h3>创建Member模块</h3>
<p>zf2创建模块的集中方法，请参考以下博客。</p>
<p><a href="http://www.qiais.com/achives/471/" title="Zend Framework 2 添加模块" target="_blank">Zend Framework 2 添加模块</a></p>
<p>我们的根目录大概是这个样子的</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-01-01.png"><img src="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-01-01-289x600.png" alt="2014-03-01-01" width="289" height="600" class="alignnone size-medium wp-image-542" /></a></p>
<p>将Member模块展开大概是这个样子的</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-01-02.png"><img src="http://www.qiais.com/wp-content/uploads/2014/03/2014-03-01-02-407x600.png" alt="2014-03-01-02" width="407" height="600" class="alignnone size-medium wp-image-543" /></a></p>
<h3>修改根目录下config/application.config.php,添加Member</h3>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
return array(
    // This should be an array of module namespaces used in the application.
    'modules' =&gt; array(
        'Application',
        'Member',  //添加这行，使Member模块有效
    ),

    // These are various options for the listeners attached to the ModuleManager
    'module_listener_options' =&gt; array(
        'module_paths' =&gt; array(
            './module',
            './vendor',
        ),

        'config_glob_paths' =&gt; array(
            'config/autoload/{,*.}{global,local}.php',
        ),
    ),
);
</pre>
<h3>修改module/Member/module.php</h3>
<p>添加getServiceConfig()函数，此函数会调用zf2的ServiceManager，注入必要的类，关于ServiceManager请参考这篇博客</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonModule for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Member;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Member\Model\User;
use Member\Model\UserTable;

class Module implements AutoloaderProviderInterface
{
    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' =&gt; array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' =&gt; array(
                'namespaces' =&gt; array(
                    __NAMESPACE__ =&gt; __DIR__ . '/src/' . str_replace('\\', '/' , __NAMESPACE__),
                ),
            ),
        );
    }

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function onBootstrap(MvcEvent $e)
    {
        $eventManager        = $e-&gt;getApplication()-&gt;getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener-&gt;attach($eventManager);
    }

    /**
     * get services
     *
     * @return array
     */
    public function getServiceConfig()
    {
        return array(
            'abstract_factories' =&gt; array(),
            'aliases' =&gt; array(),
            'factories' =&gt; array(
                // DB
                'UserTable' =&gt;  function ($sm) {
                    $tableGateway = $sm-&gt;get('UserTableGateway');
                    $table = new UserTable($tableGateway);
                    return $table;
                },
                'UserTableGateway' =&gt; function ($sm) {
                    $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype-&gt;setArrayObjectPrototype(new User());
                    return new TableGateway('users', $dbAdapter, null, $resultSetPrototype);
                },

                // FORMS
                'LoginForm' =&gt; function ($sm) {
                    $form = new \Member\Form\LoginForm();
                    $form-&gt;setInputFilter($sm-&gt;get('LoginFilter'));
                    return $form;
                },
                'RegisterForm' =&gt; function ($sm) {
                    $form = new \Member\Form\RegisterForm();
                    $form-&gt;setInputFilter($sm-&gt;get('RegisterFilter'));
                    return $form;
                },
                'UserCreateForm' =&gt; function ($sm) {
                    $form = new \Member\Form\UserCreateForm();
                    $form-&gt;setInputFilter($sm-&gt;get('UserCreateFilter'));
                    return $form;
                },
                'UserEditForm' =&gt; function ($sm) {
                    $form = new \Member\Form\UserEditForm();
                    $form-&gt;setInputFilter($sm-&gt;get('UserEditFilter'));
                    return $form;
                },
                // FILTERS
                'LoginFilter' =&gt; function ($sm) {
                    return new \Member\Form\LoginFilter();
                },
                'RegisterFilter' =&gt; function ($sm) {
                    return new \Member\Form\RegisterFilter();
                },
                'UserCreateFilter' =&gt; function ($sm) {
                    return new \Member\Form\UserCreateFilter();
                },
                'UserEditFilter' =&gt; function ($sm) {
                    return new \Member\Form\UserEditFilter();
                },
            ),
            'invokables' =&gt; array(),
            'services' =&gt; array(),
            'shared' =&gt; array(),
        );
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/540/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework2 会员管理项目之一：初始化数据库与配置</title>
		<link>http://www.qiais.com/achives/526/</link>
		<comments>http://www.qiais.com/achives/526/#comments</comments>
		<pubDate>Sat, 01 Mar 2014 02:54:55 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=526</guid>
		<description><![CDATA[本文假设Zend Framework 2 的运行环境已经搭建好。 本会员管理构架步骤如下： 一，创建数据库，初...]]></description>
				<content:encoded><![CDATA[<p>本文假设Zend Framework 2 的运行环境已经搭建好。<br />
本会员管理构架步骤如下：</p>
<h3>一，创建数据库，初始化数据表</h3>
<p>创建数据库：qiais，登录数据库的用户与密码：qiais:qiais312</p>
<pre class="brush: plain; title: ; notranslate">
# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3020
Server version: 5.1.69 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql&gt; create database qiais default character set utf8 collate utf8_gereral_ci;
mysql&gt; grant all on qiais.* to qiais@localhost identified by 'qiais';
mysql&gt; flush privileges;
</pre>
<p>创建数据库表，导入数据</p>
<pre class="brush: plain; title: ; notranslate">
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `role` varchar(10) COLLATE utf8_unicode_ci DEFAULT 'member',
  `department_id` int(4) DEFAULT '0',
  `username` varchar(60) CHARACTER SET utf8 DEFAULT NULL,
  `password` varchar(60) CHARACTER SET utf8 DEFAULT NULL,
  `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `gender` tinyint(1) DEFAULT '0',
  `email` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
  `mobile` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `tel` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  `fax` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `address` varchar(250) CHARACTER SET utf8 DEFAULT NULL,
  `zipcode` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  `memo` varchar(300) CHARACTER SET utf8 DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `modified` datetime DEFAULT NULL,
  `deleted` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=49 ;

--
-- テーブルのデータのダンプ `users`
--

INSERT INTO `users` (`id`, `role`, `department_id`, `username`, `password`, `name`, `gender`, `email`, `mobile`, `tel`, `fax`, `address`, `zipcode`, `memo`, `created`, `modified`, `deleted`) VALUES
(1, 'member', 1, 'saegusa', 'd74ddf6a8e106c6c0d0c0514d12967bd4aafbdd5', '张天明', 0, 'zhangtianming@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(2, 'member', 1, 'sugahara', '00fc474e05d0ab84ce79edd19e417d540d0f190e', '王小二', 0, 'sugahara@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(3, 'member', 1, 'miyayama', '58404c6a7c6fab7cc53a92511ed699945bb0672f', '李国立', 0, 'miyayama@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(4, 'member', 1, 'ogawa', '77a1a6222d343d5fe5e351cde1798d7b83f9f23b', '陈龙', 0, 'ogawa@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(5, 'member', 1, 'sagawa', '44db127c92f133f5d36a40bd8c73b6847beaa380', '艾心', 0, 'sagawa@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(6, 'member', 1, 't.itoh', '966cb5334889eaa9a5a6c9e39264cd7182337757', '伊東', 0, 't.itoh@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(7, 'member', 1, 'h.takeda', '502119e44b50ff25775650843b7da0d052ba269d', '竹田', 0, 'h.takeda@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(8, 'member', 1, 'sai', '7def0fd47e50c92e3b5a965e569bab5ff4d28660', '斉 街栄', 0, 'sai@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 10:20:32', 0),
(9, 'member', 1, 'h.suzuki', 'df3576b7ef690403ad5e9dfb4a89d93e88d9dd31', '鈴木', 0, 'h.suzuki@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(10, 'member', 1, 'kawaguchi', '038f9390e511855db7cc034b7ffa6d14697f0565', '川口', 0, 'kawaguchi@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(11, 'member', 1, 'kashiwabara', '1edcc5b45f7838703ede53475c9ecf9f71460bdc', '柏原', 0, 'kashiwabara@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(12, 'member', 4, 'kosugi', 'c18869fb60dcba2971940b0f7b471862611d57c6', '小杉', 0, 'kosugi@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(13, 'member', 4, 'a.yamada', 'a18816edf1b56f74b7f696ba3146bf6d2fd50017', '山田', 0, 'a.yamada@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(14, 'member', 4, 'm.takahashi', 'd45638c044b11537c3f8d0feffc7e588029dc0cf', '高橋', 0, 'm.takahashi@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(15, 'member', 4, 'r.satoh', 'e44a930af3ddf679ff3fddbb38df30a24d8c20de', '武田', 0, 'r.satoh@qiais.com', '080-7022-8514', '', NULL, '東京都足立区千住5-1-3　ｶﾞｸｴﾝﾋﾙｽﾞ北千住804', '120-0034', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(16, 'member', 4, 'nakayama', 'c11c9e6efb59f84b338136be6ea52f42f9c91d65', '中山', 0, 'nakayama@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(17, 'member', 4, 'teduka', '5ef572d0e845739cefaf8dcbe5a06ab41fe8bdea', '手塚', 0, 'teduka@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(18, 'member', 5, 'ishii', '0485a322b64d2b8b8dd60e1a7e728ad3230721c1', '石井', 0, 'ishii@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:17:59', 0),
(19, 'member', 5, 't.yamada', 'b7990b482eb77db423717875a9eb89bd1e282e14', '曹操', 0, 'caocao@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:18:23', 0),
(20, 'member', 4, 'k.suzuki', 'e89a8166c29d7d1f85d09654b3d4783f6522a00f', '薛仁贵', 0, 'xuerengui@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(21, 'member', 5, 'gunji', '36f5a9d6323b885aa6881fd9fbd6595887df937a', '程咬金', 0, 'chengyaojin@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:18:43', 0),
(22, 'member', 5, 'hori', '09a58fb3f45bb2d60af8fa16ecea73453e4058e3', '李世民', 0, 'lishimin@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:18:52', 0),
(23, 'member', 5, 'shimada', '11e721609d65f0d007f0636fbc84171bd522e79c', '島田', 0, 'shimada@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:19:01', 0),
(24, 'member', 5, 't.suzuki', '174bea76b6205f27d09c2a5563dbe9743af06c9b', '鈴木', 0, 't.suzuki@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:19:14', 0),
(25, 'member', 1, 'nakanishi', '885f1e728418ac205e3fc09142bdda164cc28cad', '中西', 0, 'nakanishi@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(26, 'member', 2, 'sakai', '629afd3de3eb222b88afad6f362ab318f44f2d1a', '酒井', 0, 'sakai@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(27, 'member', 5, 'umemoto', 'de57902f8f02182df45b5f6dadbde60900862963', '梅本', 0, 'umemoto@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:19:30', 0),
(28, 'member', 5, 'isobe', 'b9a782712864fd39abab7be5c48a27494afdbe43', '磯部', 0, 'isobe@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:19:44', 0),
(29, 'member', 5, 'awano', 'f3aaa9b9938d51419fba3202bf6d1c3dae6b3634', '粟野', 0, 'awano@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-16 02:20:03', 0),
(30, 'member', 3, 'matsuoka', '73bd07b6be35498df88eea21e1ffb30ccfddf064', '松岡', 0, 'matsuoka@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(31, 'member', 3, 'toda', 'd2749b23da3ae863db392ed0b59e46e17a684120', '戸田', 0, 'toda@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(32, 'member', 3, 'hamada', 'c8f4c129e5dd7292c8382b57561317048a10b706', '浜田', 0, 'hamada@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(33, 'member', 3, 'ohhira', 'f09b9618f82ca1643d91cdc1c12e47682a296a77', '大平', 0, 'ohhira@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(34, 'member', 3, 'h.katoh', '995d8a9417fd41146a3684e2ad6599162473fc41', '加藤', 0, 'h.katoh@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(35, 'member', 3, 'kishino', '38a26c4d27ea76f747e34b243f83005dbde38af1', '木下', 0, 'kinoshita@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(36, 'member', 3, 'nishiyama', 'cbf860f78c6f03ec02cc9cbf7675fc4f48e21df0', '西山', 0, 'nishiyama@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(37, 'member', 2, 'yamashita', '4f5a18a639a01126c1e11a71a2b969914fad50dd', '山下 功', 0, 'yamashita@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(38, 'member', 2, 'nakatani', '41895caaa4168cdc29a614793c93564833d51e4f', '中谷', 0, 'nakatani@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(39, 'member', 2, 'h.nakamura', 'f19ff6348cbcbd7c5d2712af233787549bd25893', '中村', 0, 'h.nakamura@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-17 06:59:10', 0),
(40, 'member', 2, 'y.satoh', 'fc367507fd8dfbd093073187e854440a287607b7', '佐藤', 0, 'y.satoh@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(41, 'member', 2, 'teshigawara', 'f1605a1f5875936fda6105b390adce1b95b61723', '昭和', 0, 'zhaohe@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(42, 'member', 2, 'e.fujita', '47f63dc3bc801a05486ca030b298873a1df537e4', '藤田', 0, 'e.fujita@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(43, 'member', 2, 'aritaki', '303a86d8f5898ed87be118c738fdce3db7fea1b3', '有滝', 0, 'aritaki@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-31 07:11:54', 0),
(44, 'member', 2, 'usuba', '010e3196e1f0cec1da35fe1d9a05a9f12d3d5130', '薄葉', 0, 'usuba@qiais.com', '', '', NULL, '', '', '', '2012-12-19 17:38:54', '2014-01-15 08:29:02', 0),
(45, 'member', 5, 't.kobayashi', '8f66ab1264cf52659e62fe8d4c48b0490c7c54cc', '小林', 0, 't.kobayashi@qiais.com', '', '', NULL, '', '', '', '2013-02-14 17:27:22', '2014-01-16 02:20:35', 0),
(46, 'member', 1, 'fukui', 'c16298e93b6d145adb670aa26005b3f9385b2f28', '福井', 0, 'fukui@qiais.com', '', '', NULL, '', '', '', '2013-04-24 15:19:10', '2014-01-15 08:29:02', 0),
(47, 'member', 5, '', '0d0cd58f1d09483cc5886e1f575e03a49f6c779a', '吴静安', 0, 'wujingan@qiais.com', '', '', NULL, '', '', '', '2014-01-16 02:01:08', '2014-01-16 02:20:49', 0),
(48, 'member', 5, '', 'dace7a7d4f8ba9545f37b99802fa567d41c7bef6', '山口洋介', 0, 'yamaguchi@qiais.com', '', '', NULL, '', '', '', '2014-01-16 02:04:08', '2014-01-16 02:17:25', 0);
</pre>
<h3>二，配置zf2,数据库连接</h3>
<p>config/autoload/global.php</p>
<pre class="brush: plain; title: ; notranslate">
return array(
    'db' =&gt; array(
        'driver' =&gt; 'Pdo',
        'dsn' =&gt; 'mysql:dbname=qiais_cn;host=localhost',
        'driver_options' =&gt; array(
            PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES \'UTF8\''
        ),
    ),
    'service_manager' =&gt; array(
        'factories' =&gt; array(
            'Zend\Db\Adapter\Adapter' =&gt; 'Zend\Db\Adapter\AdapterServiceFactory',
        ),
        'aliases' =&gt; array(
            'db' =&gt; 'Zend\Db\Adapter\Adapter'
        )
    ),
);
</pre>
<p>将用户名与密码配置在local.php<br />
config/autoload/local.php</p>
<pre class="brush: plain; title: ; notranslate">
return array(
    'db' =&gt; array(
        'username' =&gt; 'qiais',
        'password' =&gt; 'qiais312',
    )
);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/526/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>zend framework 2 中让空白页面显示错误信息</title>
		<link>http://www.qiais.com/achives/531/</link>
		<comments>http://www.qiais.com/achives/531/#comments</comments>
		<pubDate>Fri, 28 Feb 2014 01:50:36 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=531</guid>
		<description><![CDATA[开发软件项目时显示错误，警告等信息非常利于我们调试程序。 zend framework 2 很多设置都是在配置...]]></description>
				<content:encoded><![CDATA[<p>开发软件项目时显示错误，警告等信息非常利于我们调试程序。</p>
<p>zend framework 2 很多设置都是在配置文件中，如果设置不当，经常会碰到空白页面的情况。</p>
<p>这种情况下基本上是我们的配置或者程序中出现错误，但zf2的配置文件，以及程序代码分散的很厉害，</p>
<p>这很不利于我们判断错误到底出现在哪里。所以让错误提示显示出来就很有必要。</p>
<p>zf2显示错误提示也很简单。</p>
<p>首先在我们的服务器配置文件中添加development环境变量： SetEnv APPLICATION_ENV &#8220;development&#8221;</p>
<pre class="brush: plain; title: ; notranslate">
&lt;VirtualHost *:80&gt;
    ServerName zf2-tutorial.local
    DocumentRoot &quot;/Users/sai/Sites/valuation/public&quot;
    SetEnv APPLICATION_ENV &quot;development&quot;
    &lt;Directory &quot;/Users/sai/Sites/valuation/public&quot;&gt;
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Allow from all
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;
</pre>
<p>其次在项目根目录的public/index.php中设置error_reporting为E_ALL，display_errors为true.</p>
<p>zf2-tutorial.local/public/index.php</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
 /**
  * Display all errors when APPLICATION_ENV is development.
  */
if ($_SERVER['APPLICATION_ENV'] == 'development') {
    error_reporting(E_ALL);
    ini_set(&quot;display_errors&quot;, 1);
}

chdir(dirname(__DIR__));

// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' &amp;&amp; is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
    return false;
}

// Setup autoloading
require 'init_autoloader.php';

// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')-&gt;run();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/531/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework2  给layout传值</title>
		<link>http://www.qiais.com/achives/517/</link>
		<comments>http://www.qiais.com/achives/517/#comments</comments>
		<pubDate>Thu, 27 Feb 2014 05:01:59 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=517</guid>
		<description><![CDATA[在Zend framework2中，我们可以通过Module.php的onBootstrap函数传值给layo...]]></description>
				<content:encoded><![CDATA[<p>在Zend framework2中，我们可以通过Module.php的onBootstrap函数传值给layout</p>
<pre class="brush: plain; title: ; notranslate">
public function onBootstrap($e) {
    //获取ServiceManager
    $serviceManager = $e-&gt;getApplication()-&gt;getServiceManager();
    $viewModel = $e-&gt;getApplication()-&gt;getMvcEvent()-&gt;getViewModel();
    $viewModel-&gt;varForLayout = 'variables for layout';
}
</pre>
<p>在layout.phtml中可以通过以下代码获取变量。</p>
<pre class="brush: plain; title: ; notranslate">
$this-&gt;varForLayout
</pre>
<p>在controller文件中，我们还可以通过，以下方法给Layout传递变量。</p>
<pre class="brush: plain; title: ; notranslate">
$this-&gt;layout()-&gt;varForLayout = 'variables for layout';
</pre>
<p>同样在layout.phtml中可以通过以下代码获取变量。</p>
<pre class="brush: plain; title: ; notranslate">
$this-&gt;varForLayout
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/517/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework2 两种添加自己库的方法</title>
		<link>http://www.qiais.com/achives/509/</link>
		<comments>http://www.qiais.com/achives/509/#comments</comments>
		<pubDate>Tue, 25 Feb 2014 07:13:13 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=509</guid>
		<description><![CDATA[在ZF2中有时候我们需要添加自己的库，这里将介绍如何让ZF2识别并且加载库的两种方法。 假设我们有两个库， 一...]]></description>
				<content:encoded><![CDATA[<p>在ZF2中有时候我们需要添加自己的库，这里将介绍如何让ZF2识别并且加载库的两种方法。<br />
假设我们有两个库，</p>
<p>一个在根目录的vender文件夹中，假设名为MyLibrary；</p>
<p>另一个在我们新建的根目录的library目录中，假设名称为Qiais</p>
<h2>两种方法如下</h2>
<h3>方法一：在根目录的init_autoloader.php中直接添加</h3>
<p>在init_autoloader.php最后添加如下代码：</p>
<pre class="brush: plain; title: ; notranslate">
Zend\Loader\AutoloaderFactory::factory(array(
    'Zend\Loader\StandardAutoloader' =&gt; array(
        'namespaces' =&gt; array(
            'MyLibrary' =&gt; __DIR__ . '/vendor/MyLibrary',
            'Qiais' =&gt; __DIR__ . '/library/Qiais'
        )
    )
));
</pre>
<h3>方法二：在配置文件中添加域名路径，再在根目录的init_autoloader.php中直接加载。</h3>
<p>配置文件config/application.config.php中，添加如下代码</p>
<pre class="brush: plain; title: ; notranslate">
'autoloader' =&gt; array(
        'namespaces' =&gt; array(
            'MyLibrary' =&gt; __DIR__ . '/../vendor/MyLibrary',
            'Qiais' =&gt; __DIR__ . '/../library/Qiais'
        ),
        'autoregister_zf' =&gt; true,
    ),
</pre>
<p>再在 init_autoloader.php的底部添加如下代码：</p>
<pre class="brush: plain; title: ; notranslate">
$configuration = include 'config/application.config.php';
foreach ($configuration['autoloader']['namespaces'] as $name =&gt; $path) {
    $loader-&gt;add($name, dirname($path));
}
</pre>
<h2>最后</h2>
<p>在我们的控制文件比如：IndexController.php中只需要use namespace就可以了。</p>
<pre class="brush: plain; title: ; notranslate">
use Qiais;
Use MyLibrary;
</pre>
<p>这样，就添加了两类库，就可以饮用其中的类等文件了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/509/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend framework 2 配置多数据库</title>
		<link>http://www.qiais.com/achives/503/</link>
		<comments>http://www.qiais.com/achives/503/#comments</comments>
		<pubDate>Mon, 24 Feb 2014 08:17:01 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[zend framework 2]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=503</guid>
		<description><![CDATA[由浅入深详细剖析Zend Framework 2 数据库连接，获取数据，请点击这里。 首先，配置config/...]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.qiais.com/achives/483/" title="由浅入深详细剖析Zend Framework 2 数据库连接，获取数据" target="_blank">由浅入深详细剖析Zend Framework 2 数据库连接，获取数据，请点击这里。</a></p>
<h3>首先，配置config/auto/global.php</h3>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiais-Project
 * @package    Config
 * @subpackage Global
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Free http://www.qiai.com/license-free
 * @link       http://www.qiais.com
 */

return array(
    'db' =&gt; array(
        //这是主适配器，如果不需要使用Zend\Db\Adapter\Adapter的话，可以不配置
        'driver'         =&gt; 'Pdo',
        'dsn'             =&gt; 'mysql:dbname=qiais_cn;host=localhost',
        'username' =&gt; 'qiais',
        'password' =&gt; 'qiais312',
        'driver_options'  =&gt; array(
             PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES \'UTF8\''
         ),
        //多数据库配置
        'adapters' =&gt; array(
            'qiais_cn' =&gt; array(
                'driver' =&gt; 'Pdo',
                'dsn' =&gt; 'mysql:dbname=qiais_cn;host=localhost',
                'username' =&gt; 'qiais',
                'password' =&gt; 'qiais312',
                'driver_options' =&gt; array(
                    PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES \'UTF8\''
                ),
            ),
            'qiais_jp' =&gt; array(
                'driver' =&gt; 'Pdo',
                'dsn' =&gt; 'mysql:dbname=qiais_jp;host=localhost',
                'username' =&gt; 'qiais',
                'password' =&gt; 'qiais312',
                'driver_options' =&gt; array(
                    PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES \'UTF8\''
                ),
            ),
        )
    ),
    'service_manager' =&gt; array(
        'factories' =&gt; array(
            'Zend\Db\Adapter\Adapter'
                    =&gt; 'Zend\Db\Adapter\AdapterServiceFactory',
        ),
        'abstract_factories' =&gt; array(
            'Zend\Db\Adapter\AdapterAbstractServiceFactory',
        ),
    ),
);
</pre>
<p>这里有2个数据库，qiais_cn, qiais_jp, 因为我程序别的地方要用到Zend\Db\Adapter\Adapter，所以额外配置了主适配器。如果不需要使用Zend\Db\Adapter\Adapter的话。只要如下配置就可以：</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiais-Project
 * @package    Config
 * @subpackage Global
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Free http://www.qiai.com/license-free
 * @link       http://www.qiais.com
 */

return array(
    'db' =&gt; array(
        'adapters' =&gt; array(
            'qiais_cn' =&gt; array(
                'driver' =&gt; 'Pdo',
                'dsn' =&gt; 'mysql:dbname=qiais_cn;host=localhost',
                'username' =&gt; 'qiais',
                'password' =&gt; 'qiais312',
                'driver_options' =&gt; array(
                    PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES \'UTF8\''
                ),
            ),
            'qiais_jp' =&gt; array(
                'driver' =&gt; 'Pdo',
                'dsn' =&gt; 'mysql:dbname=qiais_jp;host=localhost',
                'username' =&gt; 'qiais',
                'password' =&gt; 'qiais312',
                'driver_options' =&gt; array(
                    PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES \'UTF8\''
                ),
            ),
        )
    ),
    'service_manager' =&gt; array(
        'abstract_factories' =&gt; array(
            'Zend\Db\Adapter\AdapterAbstractServiceFactory',
        ),
    ),
);
</pre>
<h3>编辑module/Application/src/Application/Controller/IndexController.php</h3>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
/**
 * This source file is part of Qiai.
 *
 * PHP Version &gt;=5.3
 *
 * @category   Qiais-Project
 * @package    Application
 * @subpackage Controller
 * @author     Sai (QIAI) &lt;sai@qiais.com&gt;
 * @license    Free http://www.qiai.com/license-free
 * @link       http://www.qiais.com
 */
namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Debug\Debug;
use Zend\Db\Adapter\Adapter;

/**
 * Login controller for user module
 *
 * @category   Qiais-Project
 * @package    Application
 * @subpackage Controller
 */
class IndexController extends AbstractActionController
{
    /**
     * getMutipleDB Action
     * 通过zf2配置文件，连接多个数据库，获取数据
     *
     * @return false
     */
    public function getMultipleDbAction()
    {
        //合并两数据库用的数组
        $users = array();

        //数据库 qiais_cn连接
        $qiaisCn = $this-&gt;getServiceLocator()-&gt;get('qiais_cn');
        $usersCn = $qiaisCn-&gt;query(&quot;select * from users&quot;, Adapter::QUERY_MODE_EXECUTE);
        foreach ($usersCn as $key =&gt; $cn) {
            $users[] = $cn;
        }
        
        // 数据库 qiais_jp连接
        $qiaisJp = $this-&gt;getServiceLocator()-&gt;get('qiais_jp');
        $usersJp = $qiaisJp-&gt;query(&quot;select * from users&quot;, Adapter::QUERY_MODE_EXECUTE);
        foreach ($usersJp as $key =&gt; $jp) {
            $users[] = $jp;
        }

        $viewModel = new ViewModel(array('users' =&gt; $users));
        $viewModel-&gt;setTemplate('application/index/get-data-by-code.phtml');
        return $viewModel;
    }

    /**
     * getDataByConfiguration Action
     * 通过zf2配置文件，连接数据库，获取数据
     *
     * @return false
     */
    public function getDataByConfigurationAction()
    {
        $db = $this-&gt;getServiceLocator()-&gt;get('Zend\Db\Adapter\Adapter');
        $users = $db-&gt;query(&quot;select * from users&quot;, Adapter::QUERY_MODE_EXECUTE);

        $viewModel = new ViewModel(array('users' =&gt; $users));
        $viewModel-&gt;setTemplate('application/index/get-data-by-code.phtml');
        return $viewModel;
    }

    ......
</pre>
<p>访问http://zf2-tutorial/application/index/get-multiple-db</p>
<p><a href="http://www.qiais.com/wp-content/uploads/2014/02/db-multiple-db.png"><img src="http://www.qiais.com/wp-content/uploads/2014/02/db-multiple-db-600x583.png" alt="db-multiple-db" width="600" height="583" class="alignnone size-medium wp-image-504" /></a></p>
<p>这里我们的中文数据库数据与日文数据库数据显示出来了</p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/503/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
