cakephp


Cakephp foreach


When I use foreach to show the my value in the base it show me a false value
in the controller:
public function index_hote() {
$this->Reservation->recursive = 1;
$this->loadModel("Bien");
$biens=$this->Bien->find('first',array('conditions'=>array("Bien.idBien =idBien")));
$reservations=$this->Reservation- >find('first',
array('conditions'=>array('Reservation.idBien'=> $biens['Bien'] ['idBien'])));
Debugger::dump($reservations['Reservation']);
$this->paginate('Reservation');
$this->set('reservations', $reservations['Reservation']);
}
In the view:
<?php foreach ($reservations as $reservation): ?>
<tr>
<?php echo h($reservation) ?>
<td><?php echo h($reservation['dateReserDu']); ?> </td>
<td><?php echo h($reservation['dateReserAu']); ?> </td>
<td><?php echo h($reservation['montantAPaye']); ?> </td>
<td><?php echo h($reservation['etatReservation']); ?> </td>
</tr>
<?php endforeach; ?>
When I debug it shows me the right value (the pic after doing Debugger::dump($reservations['Reservation']);):
but in the table it shows me a false value:
When I do <?php echo h($reservation) ?> it shows me the right value but when I add a attribute such as h($reservation['dateReserDu']); ?> it doesn't work PLZ why? And when can I do?
Why you are using loop here ? You have used find('first') to retrieve one data see
doc .
If you want to retrieve all data use find('all'). However if you want to echo your find 1st data just use below structure
$this->set('reservations', $reservations);
In view
echo $reservations['Reservation']['Your_field_name'];

Related Links

Groups Controller could not be found
Cakephp 2.0 + Elements + requestAction = empty result
CakePHP Sharing code between helpers
how to load or use a Model in a Component File especially in Cakephp 2.0?
$this->Auth->login() creates correct query that returns 1 row, but fails IF check (server specific issue)
Is it possible to insert all related records in a HABTM at once with saveAll in Cakephp?
Caching controller action in CakePHP
CakePHP Cron Job on GoDaddy
CakePHP 1.3 HABTM - Add works fine, Edit will not save HABTMs
CakePHP displaying “admi” at the top of any page
CakePHP load javascript components when needed
Uploading and saving files in CakePHP 2.1
update Auth session
External Link cake php
CakePHP Routes and Pagination
CakePHP: how do I order a model from the values in another?

Categories

HOME
vim
wso2-am
oracle11g
single-sign-on
push-notification
mfc
relay
youtube-dl
rdf
jxls
disassembler
ezpublish
directx
node-notifier
esper
gorm
orchardcms
visual-studio-2005
reactcsstransitiongroup
normalizr
text-rendering
tar
autosys
tdd
maxmind
msys2
tasklet
madlib
bluestacks
media-queries
y86
dosbox
retina-display
lto
theano.scan
ssjs
reportbuilder
hp-ux
powershell-dsc
firebase-admin
total-commander
dotcover
zip4j
python-webbrowser
snmptrapd
nsarray
namecoin
qtwebview
python-cryptography
pdfclown
imanage
bind9
titanium-android
minimization
smart-table
spring-android
angular-cache
instant
libpng
py2app
thrust
nsviewcontroller
persist
master-slave
php-internals
pyke
xna-4.0
msys
comobject
spidermonkey
libressl
tarjans-algorithm
map-projections
operation
cisco-ios
angular-local-storage
pretty-print
dereference
notify
bigbluebutton
cctv
dml
oam
dir
sitemesh
inbox
mylyn
typoscript2
bitsharp
venn-diagram
cascalog
ticoredatasync
transactionscope
celltable
mozilla-prism
msdev

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App