Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // In module/Blog/src/Mapper/ZendDbSqlRepository.php:
- namespace Blog\Mapper; //path changed
- use InvalidArgumentException;
- use RuntimeException;
- use Zend\Db\Adapter\AdapterInterface;
- use Zend\Db\Sql\Sql;
- class ZendDbSqlRepository implements PostRepositoryInterface
- {
- /**
- * {@inheritDoc}
- */
- private $db;
- public function __construct(AdapterInterface $db)
- {
- $this->db = $db;
- }
- public function findAllPosts()
- {
- $sql = new Sql($this->db); //changed from $this->dbAdapter
- $select = $sql->select('posts');
- $stmt = $sql->prepareStatementForSqlObject($select);
- $result = $stmt->execute();
- return $result;
- }
- /**
- * {@inheritDoc}
- * @throws InvalidArgumentException
- * @throws RuntimeException
- */
- public function findPost($id)
- {
- }
- }
- /*
- // In module/Blog/src/Model/ZendDbSqlRepository.php:
- namespace Blog\Mapper;
- use InvalidArgumentException;
- use RuntimeException;
- use Zend\Db\Adapter\AdapterInterface;
- use Zend\Db\Sql\Sql;
- use Blog\Model\PostRepositoryInterface;
- class ZendDbSqlRepository implements PostRepositoryInterface
- {
- /**
- * {@inheritDoc}
- */
- private $db;
- public function __construct(AdapterInterface $db)
- {
- $this->db = $db;
- }
- public function findAllPosts()
- {
- $sql = new Sql($this->dbAdapter);
- $select = $sql->select('posts');
- $stmt = $sql->prepareStatementForSqlObject($select);
- $result = $stmt->execute();
- return $result;
- }
- /**
- * {@inheritDoc}
- * @throws InvalidArgumentException
- * @throws RuntimeException
- */
- public function findPost($id)
- {
- }
- }*/
Add Comment
Please, Sign In to add comment