Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php
declare(strict_types=1);

namespace LeadersLinked\Mapper;


use LeadersLinked\Mapper\Common\MapperCommon;
use Laminas\Db\Adapter\AdapterInterface;
use LeadersLinked\Model\Application;


class ApplicationMapper extends MapperCommon
{
    const _TABLE = 'tbl_applications';

    /**
     *
     * @var ApplicationMapper
     */
    private static $_instance;
    
    /**
     *
     * @param AdapterInterface $adapter
     */
    private function __construct($adapter)
    {
        parent::__construct($adapter);
    }
    
    /**
     *
     * @param AdapterInterface $adapter
     * @return ApplicationMapper
     */
    public static function getInstance($adapter)
    {
        if(self::$_instance == null) {
            self::$_instance = new ApplicationMapper($adapter);
        }
        return self::$_instance;
    }
    
    /**
     * 
     * @param int $id
     * @return Application
     */
    public function fetchOne($id)
    {
        $prototype = new Application();
        
        
        $select = $this->sql->select(self::_TABLE);
        $select->where->equalTo('id', $id);
        
        $prototype = new Application();
        return $this->executeFetchOneObject($select, $prototype);
    }
    
    
    

    
    /**
     *
     * @return Application[]
     */
    public function fetchAll()
    {
        
        $select = $this->sql->select(self::_TABLE);
        
        $prototype = new Application();
        return $this->executeFetchAllObject($select, $prototype);
    }
    
}