public function indexAction()
{
return new ViewModel(array(
- 'Galerie_all' => $this->_getGalerieTable()->all(),
- 'Galerie_one' => $this->_getGalerieTable()->get(1),
- 'GalerieInfo_all' => $this->_getGalerieInfoTable()->select(),
- 'GalerieInfo_one' => $this->_getGalerieInfoTable()->select(array('gallery.id' => 1))->current(),
- 'GalerieInfo_usr' => $this->_getGalerieInfoTable()->select(array('gallery.id_user' => 1)),
+ 'all' => $this->_getGalerieInfoTable()->all(),
));
}
throw new \Exception('delete is not allowed');
}
+ public function all()
+ {
+ return $this->select();
+ }
+
+ public function one($id)
+ {
+ if ($id === null) {
+ $row = null;
+ } else {
+ $row = $this->select(array('gallery.id' => (int) $id))->current();
+ }
+ if (!$row) {
+ throw new \Exception("cannot get row {id: {$id}} in table 'galerie'");
+ }
+ return $row;
+ }
+
+ public function any($id)
+ {
+ if ($id === null) {
+ $row = null;
+ } else {
+ $row = $this->select(array('gallery.id' => (int) $id))->current();
+ }
+ return $row;
+ }
+
+ public function all_by_user($id_user)
+ {
+ return $this->select(array('gallery.id_user' => (int) $id_user));
+ }
+
}
<h1>Galerie</h1>
-<h2>test de fetchAll()</h2>
-
-<pre><?php echo $Galerie_all->count(); ?></pre>
-<pre><?php print_r($Galerie_all->toArray()); ?></pre>
-
-<h2>test de getGalerie</h2>
-
-<pre><?php print_r($Galerie_one); ?></pre>
-<p>Identifiant : <?php echo $Galerie_one->id; ?></p>
-
-
-<h1>GalerieInfo</h1>
-<h2>test de select()</h2>
-
-<pre><?php echo $GalerieInfo_all->count(); ?></pre>
-<pre><?php print_r($GalerieInfo_all->toArray()); ?></pre>
-
-<pre><?php print_r($GalerieInfo_one); ?></pre>
-
-<pre><?php echo $GalerieInfo_usr->count(); ?></pre>
-<pre><?php print_r($GalerieInfo_usr->toArray()); ?></pre>
+<h2>test de la méthode all()</h2>
+<pre><?php echo $all->count(); ?></pre>
+<pre><?php print_r($all->toArray()); ?></pre>