<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                為了方便講解與引用,將認證類放在Album模塊的模型目錄下。用戶認證的方式有多種,在這里介紹的一種是作者在開發中常用到的一種,數據庫認證的持久性認證。ZF2中的持久性認證其本質還是通過Session來實現的,只不過開發者在開發的時候根據就不會察覺到Session在這期間的存在。ZF2在使用持久性認證的時候如果沒有對認證空間進行重新命名,ZF2使用使用一個Zend_auth為其Session的默認命名空間,當你在new一個認證的實例的時候系統會自動的找到Zend_auth對應的Session命名空間。在此也可以看認證類與其他類在進行new 的時候可能會有所不同,這種不同也正是由于Session的相關機制所帶來的。 添加文件:`/module/Album/src/Album/Model.MyAuth.php`,具體內容如下: ~~~ namespace Album\Model; use Zend\Db\Adapter\Adapter as DbAdapter; use Zend\Authentication\Adapter\DbTable as AuthAdapter; use Zend\Authentication\AuthenticationService; class MyAuth { protected $adapter; public function __construct() { $this->adapter = new DbAdapter(array( 'driver'=>'Pdo_Mysql', 'database'=>'test', 'host'=>'localhost', 'username'=>'root', 'password'=>'' )); } public function auth() { $authAdapter = new AuthAdapter($this->adapter); $authAdapter ->setTableName('user') // 認證的數據表 ->setIdentityColumn('username') // 認證字段 ->setCredentialColumn('password'); // 校驗字段 $authAdapter ->setIdentity('admin') // 認證值 ->setCredential('admin');// 校驗值 $auth = new AuthenticationService(); $result = $auth->authenticate($authAdapter); if($result->isValid()){ $auth->getStorage()->write($authAdapter->getResultRowObject()); return true; } return false; } public function isAuth(){ $auth = new AuthenticationService(); if($auth->hasIdentity()) return true; return false; } } ~~~ 代碼解釋: public function auth() {} 進行認證 public function isAuth(){} 通過持久性認證判斷是否已經通過認證 $authAdapter = new AuthAdapter($this->adapter); 實例為一個認證適配器 $auth = new AuthenticationService(); 實例化一個認證服務,以實現持久性認證
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看