X-Git-Url: http://git.inspyration.org/?p=zf2.biz%2Fgalerie.git;a=blobdiff_plain;f=module%2FGalerie%2Fsrc%2FGalerie%2FModel%2FGalerieInfoTable.php;h=3d5890b192eebfde51738a1d0508ce49f675577a;hp=a0b3421fb76b91353b39648960b487241c1ab6d9;hb=709825fa5a4a684beb5f484ba19e976543493f48;hpb=a5ce38aad48431412e69ff317c571b0b1f2e0ee9 diff --git a/module/Galerie/src/Galerie/Model/GalerieInfoTable.php b/module/Galerie/src/Galerie/Model/GalerieInfoTable.php index a0b3421..3d5890b 100644 --- a/module/Galerie/src/Galerie/Model/GalerieInfoTable.php +++ b/module/Galerie/src/Galerie/Model/GalerieInfoTable.php @@ -5,6 +5,7 @@ use Zend\Db\Adapter\Adapter; use Zend\Db\ResultSet\ResultSet; use Zend\Db\TableGateway\TableGatewayInterface; use Zend\Db\Sql\Sql; +use Zend\Db\Sql\Where; use Custom\Model\Entity; @@ -40,7 +41,7 @@ class GalerieInfoTable implements TableGatewayInterface } - public function select($where = null) + public function select($where = null, $order = null, $limit = null, $offset = null) { $select = $this->sql->select() ->columns(array('id', 'name', 'description')) @@ -63,6 +64,15 @@ class GalerieInfoTable implements TableGatewayInterface if ($where) { $select->where($where); } + if ($order) { + $select->order($order); + } + if ($limit) { + $select->limit($limit); + } + if ($offset) { + $select->offset($offset); + } // prepare and execute $statement = $this->sql->prepareStatementForSqlObject($select); @@ -120,4 +130,33 @@ class GalerieInfoTable implements TableGatewayInterface return $this->select(array('gallery.id_user' => (int) $id_user)); } + + + + public function count_all() + { + $select = $this->sql->select()->columns(array( + 'nb' => new \Zend\Db\Sql\Expression('count(gallery.id)') + )); + + // prepare and execute + $statement = $this->sql->prepareStatementForSqlObject($select); + $result = $statement->execute()->current(); + + return $result['nb']; + } + + public function getPartial($start, $length, $tri, $senstri, $filtre) + { + $where = new Where; + $where->like('gallery.name', "%{$filtre}%"); + $where->or; + $where->like('gallery.description', "%{$filtre}%"); + + return $this->select($where, "{$tri} {$senstri}", $length, $start); + } + + + + }