Chyba pri referencii – forign key
- majo1
- Člen | 103
Zdravim,
uz ste sa niekto stretli s tym, ze sa v latte napr.
{$reservation->ref(‚skibuses‘,
‚skibus_idskibus‘)->departureDatetime} nechce vykonat, a pre ostatne
tabulky (FK) ano?
Vsetko funguje, len ak spravim referenciu na riadku 58, tak tracy vypise chybu „Argument count does not match placeholder count.“
48: <td><?php echo Latte\Runtime\Filters::escapeHtml(date("d.m.Y, G:i", strtotime($reservation->datetime)), ENT_NOQUOTES) ?></td>
49: <td><?php echo Latte\Runtime\Filters::escapeHtml($reservation->numAdult + $reservation->numJunior + $reservation->numKid + $reservation->numTransportOnly, ENT_NOQUOTES) ?></td>
50: <td><?php if ($reservation->confirmed == 0) { ?>
51: <i class="fa fa-times"></i><?php } else { ?><i class="fa fa-check"></i><?php } ?></td>
52: <td><?php if ($reservation->paid == 0) { ?>
53: <i class="fa fa-times"></i><?php } else { ?><i class="fa fa-check"></i><?php } ?></td>
54: <td><?php if ($reservation->variable == 0) { ?>
55: Nepriradený<?php } else { ?>$reservation->variable<?php } ?></td>
56: <td><?php echo Latte\Runtime\Filters::escapeHtml($reservation->ref('customers', 'customer_idcustomer')->name, ENT_NOQUOTES) ?>
57: <?php echo Latte\Runtime\Filters::escapeHtml($reservation->ref('customers', 'customer_idcustomer')->surename, ENT_NOQUOTES) ?></td>
58: <td> <?php echo Latte\Runtime\Filters::escapeHtml($reservation->ref('skibuses', 'skibus_idskibus')->departureDatetime, ENT_NOQUOTES) ?></td>
59: <td><?php echo Latte\Runtime\Filters::escapeHtml($reservation->ref('stations', 'station_idstation')->city, ENT_NOQUOTES) ?>
60: , <?php echo Latte\Runtime\Filters::escapeHtml($reservation->ref('stations', 'station_idstation')->departureTime, ENT_NOQUOTES) ?></td>
61: <td><?php echo Latte\Runtime\Filters::escapeHtml($reservation->ref('centers', 'center_idcenter')->centerName, ENT_NOQUOTES) ?></td>
62: <td>
inak ked dam miesto riadka {$reservation->skibus_idskibus} tak sa vypise FK bez chyby.
- Pavel Kravčík
- Člen | 1195
A není to tou čárkou navíc? :)
ref(‚skibuses‘, ‚skibus_idskibus‘)
→
ref(‚skibuses‘, skibus_idskibus‘)
Editoval Pavel Kravčík (8. 2. 2016 13:55)
- majo1
- Člen | 103
prosím Vás, neviete niekto, kde môže byť problém?
nie je to nejaký bug?
skibus_idskibus je FK ako každý iný a neviem prečo pri ostatných ref
funguje a pri tomto nie :(
„Argument count does not match placeholder count.“
{$reservation->ref('skibuses', 'skibus_idskibus')->departureDatetime}
Celý foreach vyzerá takto
<tr n:foreach="$reservations as $reservation" >
<td>{$reservation->idreservation}</td>
<td>{date("d.m.Y, G:i", strtotime($reservation->datetime))}</td>
<td><span data-toggle="tooltip" title="
Dospelí: {$reservation->numAdult} / Juniori: {$reservation->numJunior} / Deti: {$reservation->numKid} / Len doprava: {$reservation->numTransportOnly}
">{$reservation->numAdult + $reservation->numJunior + $reservation->numKid + $reservation->numTransportOnly}</span></td>
<td>{if $reservation->confirmed == 0}<i class="fa fa-times"></i>{else}<i class="fa fa-check"></i>{/if}</td>
<td>{if $reservation->paid == 0}<i class="fa fa-times"></i>{else}<i class="fa fa-check"></i>{/if}</td>
<td>{if $reservation->variable == 0}Nepriradený{else}$reservation->variable{/if}</td>
<td><span data-toggle="tooltip" title="Telefón: {$reservation->ref('customers', 'customer_idcustomer')->telephone}">{$reservation->ref('customers', 'customer_idcustomer')->name} {$reservation->ref('customers', 'customer_idcustomer')->surename}</span></td>
<td>{$reservation->skibus_idskibus} {$reservation->ref('skibuses', 'skibus_idskibus')->departureDatetime}</td>
<td>{$reservation->ref('stations', 'station_idstation')->city}, {$reservation->ref('stations', 'station_idstation')->departureTime}</td>
<td>{$reservation->ref('centers', 'center_idcenter')->centerName}</td>
<td>
<div class="btn-group">
<a n:href=":Reservation:editor $reservation->idreservation"><button type="button" class="btn btn-default"><i class="fa fa-pencil"></i></button></a>
<a n:href=":Reservation:remove $reservation->idreservation"><button type="button" class="btn btn-default"><i class="fa fa-trash"></i></button></a>
</div>
</td>
</tr>
chybu pise tracy na riadku 115
105: <?php $iterations = 0; foreach ($flashes as $flash) { ?> <div style="padding: 15px;">
106: <div class="box-body alert alert-info alert-dismissable">
107: <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
108: <h4><i class="icon fa fa-info"></i> Oznámenie systému</h4>
109: <?php echo Latte\Runtime\Filters::escapeHtml($flash->message, ENT_NOQUOTES) ?>
110:
111: </div>
112: </div>
113: <?php $iterations++; } ?>
114:
115: <?php Latte\Macros\BlockMacrosRuntime::callBlock($_b, 'content', $template->getParameters()) ;call_user_func(reset($_b->blocks['scripts']), $_b, get_defined_vars()) ?>
116:
117: </div>
118:
119: <footer class="main-footer">
Editoval majo1 (12. 2. 2016 11:56)
- David Matějka
- Moderator | 6445
muzes ukazat strukturu db? nejlepe dump.. tohle je opravdu divna chyba
- majo1
- Člen | 103
prikladam moju databazu
http://pastebin.com/VvmCL7J1
Editoval majo1 (12. 2. 2016 22:23)
- David Matějka
- Moderator | 6445
problem budou asi ty slozene primarni klice. ndbt s nima IIRC neumi dobre pracovat. pouzij jen PK nad jednim sloupeckem (ten, ktery ma auto_increment)
- David Matějka
- Moderator | 6445
no tak customers ma jen PK idcustomer, stations ma jen idstation, ale skibuses ma slozeny PK z idskibus a centers_idcenter.
proste krom m:n spojovacich tabulek pouzivej jen PK nad jednim sloupeckem
- majo1
- Člen | 103
to je nejake divne.
databazu som modeloval vo workbench a tam ziadny m:n vztah nemam
https://i.imgsafe.org/355781a.png
- David Matějka
- Moderator | 6445
vim, rikam jen kde by se PK pres vice sloupecku mel pouzivat. Ale ty tam mas PK pres vice sloupecku u tabulek reservations a skibuses
- David Matějka
- Moderator | 6445
jak propojene? to propojis pomoci FK, primary key nech jen jeden sloupecek