• 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));
        }
    
    }
  • 相关阅读:
    Flesch Reading Ease(模拟)
    实验一:词法分析设计
    java—容器学习笔记
    [转载]马士兵Java视频教程 —— 学习顺序
    Java的安装过程
    编程之美初赛第一场
    RCC 2014 Warmup (Div. 2)
    ural 1017. Staircases(dp)
    ural 1012. K-based Numbers. Version 2(大数dp)
    ural 1009. K-based Numbers(简单dp)
  • 原文地址:https://www.cnblogs.com/xuyaoxiang/p/3037750.html
Copyright © 2020-2023  润新知