zoukankan      html  css  js  c++  java
  • albumTable.php

    <?php
    
    namespace Album\Model;
    
    use Zend\Db\TableGateway\AbstractTableGateway;
    use Zend\Db\Adapter\Adapter;
    use Zend\Db\ResultSet\ResultSet;
    
    class AlbumTable extends AbstractTableGateway
    {
        protected $table = 'aii_user';
    
        public function __construct(Adapter $adapter)
        {
            $this->adapter = $adapter;
            $this->resultSetPrototype = new ResultSet();
            $this->resultSetPrototype->setArrayObjectPrototype(new Album());
    
            $this->initialize();
        }
    
        public function fetchAll()
        {
            $resultSet = $this->select();
            return $resultSet;
        }
    
        public function getAlbum($id)
        {
            $id  = (int) $id;
            $rowset = $this->select(array('id' => $id));
            $row = $rowset->current();
            if (!$row) {
                throw new \Exception("Could not find row $id");
            }
            return $row;
        }
        
         public function checkReg($aii_username)
        {
            $aii_username  = $aii_username;
            $rowset = $this->select(array('aii_username' => $aii_username));
            $row = $rowset->current();
            if ($row) {
                throw new \Exception("this username already reg");
            }
            return true;
        } //检查该用户名是否被注册
        
         public function checkLogin($aii_username,$aii_password)
        {
            $aii_username  = $aii_username;
            $aii_password=$aii_password;
            $rowset = $this->select(array('aii_username' => $aii_username,'aii_password'=>$aii_password));
            $row = $rowset->current();
            if (!$row) {
                throw new \Exception("the username or password is wrong");
            }
            return true;
        } //验证登录
    
        public function saveAlbum(Album $album)
        {
            $data = array(
                'aii_username' => $album->aii_username,
                'aii_password'  => $album->aii_password,
            );
            $this->checkReg($data['aii_username']);
            $id = (int)$album->id;
            if ($id == 0) {
                $this->insert($data);
            } else {
                if ($this->getAlbum($id)) {
                    $this->update($data, array('id' => $id));
                } else {
                    throw new \Exception('Form id does not exist');
                }
            }
        }
    
        public function deleteAlbum($id)
        {
            $this->delete(array('id' => $id));
        }
    
    }
  • 相关阅读:
    laravel5.2 开发中打印sql语句
    centos 安装 vsftpd
    linux 安装 DenyHosts 防止密码被暴力破解
    linux nginx 安装防火墙ngx_lua_waf
    mysql 下载资源地址
    微信公众号 access_token 没有过期 却失效
    centos 安装 composer
    五十个小技巧提高PHP执行效率
    yii 使用DB实现rbac 权限控制
    git 的使用
  • 原文地址:https://www.cnblogs.com/xuyaoxiang/p/3037750.html
Copyright © 2011-2022 走看看