나는 테이블이 다음과 같은 속성을 가진, Bookings
라고 있습니다CakePHP의 3 - 속성은 테이블에 표시되지
id
artist_id
- 외래 키status
amount
created
modified
는 그것은 테이블 Artists
, Payments
및 Sessions
와 연결되어 있습니다.
- 그들의
status
는 - 관련 테이블
Session's
속성 DATE_END보다 커야합니다 '확인'과 같다 :보기에 , 나는 다음과 같은 조건을 충족Bookings
를 표시 할 jQuery 플러그인의 DataTables를 사용했다 현재 날짜.
그러나 페이지를로드 할 때 amount
속성은 $ 0.00으로 표시되며, 기본적으로 null이지만 그 밖의 모든 항목은 정상적으로 표시됩니다. CakePHP 변수에서, amount
속성은 공백으로 표시됩니다. 그러나 MySQL에서는 amount
이 비어 있지 않은 것으로 명시되어 있습니다. 다음은
<table class="bookingsTables display" id="confirmedTable">
<thead>
<tr>
<th scope="col"><?= $this->Paginator->sort('name', 'Artist') ?></th>
<th scope="col"><?= $this->Paginator->sort('date_start', 'Start Date') ?></th>
<th scope="col"><?= $this->Paginator->sort('date_end', 'End Date') ?></th>
<th scope="col"><?= $this->Paginator->sort('studio_id', 'Studio') ?></th>
<th scope="col"><?= $this->Paginator->sort('engineer_id', 'Engineer') ?></th>
<th scope="col"><?= $this->Paginator->sort('amount', 'Total Amount') ?></th>
<th scope="col"><?= $this->Paginator->sort('status', 'Payment Status') ?></th>
<th scope="col" class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($bookingsConfirmed as $booking): ?>
<tr>
<td><?= $booking->has('artist') ? h($booking->artist->name) : '' ?></td>
<td><?= $booking->has('session') ? h($booking->session->date_start) : '' ?></td>
<td><?= $booking->has('session') ? h($booking->session->date_end) : '' ?></td>
<td><?= $booking->session->has('studio') ? h($booking->session->studio->name) : '' ?></td>
<td><?= $booking->session->has('engineer') ? h($booking->session->engineer->eng_firstname . ' ' . $booking->session->engineer->eng_lastname) :'' ?></td>
<td><?= h($this->Number->currency($booking->amount)) ?></td>
<td><?= h($paymentStatusLookup[$booking->id]); ?></td>
<td class="actions">
<?= $this->Html->link(__('Update'), ['action' => 'bookingconfirm', $booking->id]) ?>
<?= $this->Html->link(__('View'), ['action' => 'view', $booking->id]) ?>
<p>Cancel</p>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
$ paymentStatusLookup [$ 예약 -> ID];
위의 행은 지불을위한 가상 상태이지만 내 금액 값이 누락 된 이유와 관련이 있는지는 잘 모르겠습니다. 내 테이블에서이 라인을 제거하여 차이가 있는지 확인했습니다. (약간 다른 조건 임에도 불구하고 비슷한 것을 보여주는 두 개의 다른 DataTable이 있고 amount
이 테이블에 정상적으로 표시됨)하지만 그렇지 않았습니다.
$ this-> 번호 -> 통화
이것은 단지 $ 0.00에 널 (null)/빈 필드를 돌았 다. 내가 예약 모델의 최근 케이크 베이킹을했다
public function validationDefault(Validator $validator)
{
$validator
->integer('id')
->allowEmpty('id', 'create');
$validator
->requirePresence('status', 'create')
->notEmpty('status');
$validator
->decimal('amount')
->allowEmpty('amount');
return $validator;
}
: 내 컨트롤러에서
이 특정 테이블에 해당 찾기 다음 validationDefault 기능 내 예약 표에서
$bookingsConfirmed = $this->Bookings->find('all',[
'contain' => ['Sessions', 'Sessions.Studios', 'Sessions.Engineers', 'Artists'],
'conditions'=>['status' => 'confirmed', date_end >=' => date('Y-m-d H:i:s', Time::now()->getTimestamp())],
'order'=>['Bookings.created'=>'ASC']
]);
, 게다가.
업데이트 :
object(Cake\ORM\Query) {
'(help)' => 'This is a Query object, to get the results execute or iterate it.',
'sql' => 'SELECT Bookings.id AS `Bookings__id`, Bookings.artist_id AS `Bookings__artist_id`, Bookings.status AS `Bookings__status`, Bookings.amount AS `Bookings__amount`, Bookings.created AS `Bookings__created`, Bookings.modified AS `Bookings__modified`, Sessions.id AS `Sessions__id`, Sessions.booking_id AS `Sessions__booking_id`, Sessions.studio_id AS `Sessions__studio_id`, Sessions.engineer_id AS `Sessions__engineer_id`, Sessions.guestengineer_id AS `Sessions__guestengineer_id`, Sessions.date_start AS `Sessions__date_start`, Sessions.date_end AS `Sessions__date_end`, Sessions.starttime AS `Sessions__starttime`, Sessions.hours AS `Sessions__hours`, Sessions.session_genre AS `Sessions__session_genre`, Sessions.no_people AS `Sessions__no_people`, Sessions.studio_usage AS `Sessions__studio_usage`, Sessions.otherpeople_req AS `Sessions__otherpeople_req`, Sessions.special_req AS `Sessions__special_req`, Sessions.created AS `Sessions__created`, Sessions.modified AS `Sessions__modified`, Studios.id AS `Studios__id`, Studios.name AS `Studios__name`, Studios.description AS `Studios__description`, Studios.created AS `Studios__created`, Studios.modified AS `Studios__modified`, Engineers.id AS `Engineers__id`, Engineers.user_id AS `Engineers__user_id`, Engineers.eng_firstname AS `Engineers__eng_firstname`, Engineers.eng_lastname AS `Engineers__eng_lastname`, Engineers.eng_email AS `Engineers__eng_email`, Engineers.eng_phoneno AS `Engineers__eng_phoneno`, Engineers.eng_status AS `Engineers__eng_status`, Engineers.rate AS `Engineers__rate`, Engineers.created AS `Engineers__created`, Engineers.modified AS `Engineers__modified`, Artists.id AS `Artists__id`, Artists.name AS `Artists__name`, Artists.cp_id AS `Artists__cp_id`, Artists.user_id AS `Artists__user_id`, Artists.genre AS `Artists__genre`, Artists.created AS `Artists__created`, Artists.modified AS `Artists__modified` FROM bookings Bookings LEFT JOIN sessions Sessions ON Bookings.id = (Sessions.booking_id) INNER JOIN studios Studios ON Studios.id = (Sessions.studio_id) LEFT JOIN engineers Engineers ON Engineers.id = (Sessions.engineer_id) INNER JOIN artists Artists ON Artists.id = (Bookings.artist_id) WHERE (status = :c0 AND Sessions.date_end < :c1) ORDER BY Bookings.created ASC',
'params' => [
':c0' => [
'value' => 'confirmed',
'type' => 'string',
'placeholder' => 'c0'
],
':c1' => [
'value' => '20/2/17, 4:34 p02',
'type' => null,
'placeholder' => 'c1'
]
],
'defaultTypes' => [
'Bookings__id' => 'integer',
'Bookings.id' => 'integer',
'id' => 'integer',
'Bookings__artist_id' => 'integer',
'Bookings.artist_id' => 'integer',
'artist_id' => 'integer',
'Bookings__status' => 'string',
'Bookings.status' => 'string',
'status' => 'string',
'Bookings__amount' => 'decimal',
'Bookings.amount' => 'decimal',
'amount' => 'decimal',
'Bookings__created' => 'datetime',
'Bookings.created' => 'datetime',
'created' => 'datetime',
'Bookings__modified' => 'datetime',
'Bookings.modified' => 'datetime',
'modified' => 'datetime',
'Sessions__id' => 'integer',
'Sessions.id' => 'integer',
'Sessions__booking_id' => 'integer',
'Sessions.booking_id' => 'integer',
'booking_id' => 'integer',
'Sessions__studio_id' => 'integer',
'Sessions.studio_id' => 'integer',
'studio_id' => 'integer',
'Sessions__engineer_id' => 'integer',
'Sessions.engineer_id' => 'integer',
'engineer_id' => 'integer',
'Sessions__guestengineer_id' => 'integer',
'Sessions.guestengineer_id' => 'integer',
'guestengineer_id' => 'integer',
'Sessions__date_start' => 'date',
'Sessions.date_start' => 'date',
'date_start' => 'date',
'Sessions__date_end' => 'date',
'Sessions.date_end' => 'date',
'date_end' => 'date',
'Sessions__starttime' => 'time',
'Sessions.starttime' => 'time',
'starttime' => 'time',
'Sessions__hours' => 'integer',
'Sessions.hours' => 'integer',
'hours' => 'integer',
'Sessions__session_genre' => 'text',
'Sessions.session_genre' => 'text',
'session_genre' => 'text',
'Sessions__no_people' => 'integer',
'Sessions.no_people' => 'integer',
'no_people' => 'integer',
'Sessions__studio_usage' => 'text',
'Sessions.studio_usage' => 'text',
'studio_usage' => 'text',
'Sessions__otherpeople_req' => 'text',
'Sessions.otherpeople_req' => 'text',
'otherpeople_req' => 'text',
'Sessions__special_req' => 'text',
'Sessions.special_req' => 'text',
'special_req' => 'text',
'Sessions__created' => 'datetime',
'Sessions.created' => 'datetime',
'Sessions__modified' => 'datetime',
'Sessions.modified' => 'datetime',
'Studios__id' => 'integer',
'Studios.id' => 'integer',
'Studios__name' => 'string',
'Studios.name' => 'string',
'name' => 'string',
'Studios__description' => 'text',
'Studios.description' => 'text',
'description' => 'text',
'Studios__created' => 'datetime',
'Studios.created' => 'datetime',
'Studios__modified' => 'datetime',
'Studios.modified' => 'datetime',
'Engineers__id' => 'integer',
'Engineers.id' => 'integer',
'Engineers__user_id' => 'integer',
'Engineers.user_id' => 'integer',
'user_id' => 'integer',
'Engineers__eng_firstname' => 'string',
'Engineers.eng_firstname' => 'string',
'eng_firstname' => 'string',
'Engineers__eng_lastname' => 'string',
'Engineers.eng_lastname' => 'string',
'eng_lastname' => 'string',
'Engineers__eng_email' => 'string',
'Engineers.eng_email' => 'string',
'eng_email' => 'string',
'Engineers__eng_phoneno' => 'integer',
'Engineers.eng_phoneno' => 'integer',
'eng_phoneno' => 'integer',
'Engineers__eng_status' => 'string',
'Engineers.eng_status' => 'string',
'eng_status' => 'string',
'Engineers__rate' => 'decimal',
'Engineers.rate' => 'decimal',
'rate' => 'decimal',
'Engineers__created' => 'datetime',
'Engineers.created' => 'datetime',
'Engineers__modified' => 'datetime',
'Engineers.modified' => 'datetime',
'Artists__id' => 'integer',
'Artists.id' => 'integer',
'Artists__name' => 'string',
'Artists.name' => 'string',
'Artists__cp_id' => 'integer',
'Artists.cp_id' => 'integer',
'cp_id' => 'integer',
'Artists__user_id' => 'integer',
'Artists.user_id' => 'integer',
'Artists__genre' => 'text',
'Artists.genre' => 'text',
'genre' => 'text',
'Artists__created' => 'datetime',
'Artists.created' => 'datetime',
'Artists__modified' => 'datetime',
'Artists.modified' => 'datetime'
],
'decorators' => (int) 0,
'executed' => false,
'hydrate' => true,
'buffered' => true,
'formatters' => (int) 0,
'mapReducers' => (int) 0,
'contain' => [
'Sessions' => [
'Studios' => [],
'Engineers' => []
],
'Artists' => []
],
'matching' => [],
'extraOptions' => [],
'repository' => object(App\Model\Table\BookingsTable) {
'registryAlias' => 'Bookings',
'table' => 'bookings',
'alias' => 'Bookings',
'entityClass' => 'App\Model\Entity\Booking',
'associations' => [
(int) 0 => 'artists',
(int) 1 => 'payments',
(int) 2 => 'sessions'
],
'behaviors' => [
(int) 0 => 'Timestamp'
],
'defaultConnection' => 'default',
'connectionName' => 'default'
}
}
업데이트 : 디버그 ($ 예약) 한 기록을 사용하여, 다음과 같다 :
object(App\Model\Entity\Booking) {
'id' => (int) 133,
'artist_id' => (int) 6,
'status' => 'confirmed',
'amount' => '',
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2017-02-20T16:27:15+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2017-02-20T16:32:08+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'artist' => object(App\Model\Entity\Artist) {
'id' => (int) 6,
'name' => 'test1',
'cp_id' => (int) 6,
'user_id' => (int) 25,
'genre' => 'Anything really.',
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2017-01-30T08:57:41+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2017-01-30T08:57:41+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Artists'
},
'session' => object(App\Model\Entity\Session) {
'id' => (int) 100,
'booking_id' => (int) 133,
'studio_id' => (int) 2,
'engineer_id' => (int) 2,
'guestengineer_id' => null,
'date_start' => object(Cake\I18n\FrozenDate) {
'time' => '2017-02-28T00:00:00+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'date_end' => object(Cake\I18n\FrozenDate) {
'time' => '2017-03-14T00:00:00+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'starttime' => null,
'hours' => null,
'session_genre' => 'tests',
'no_people' => (int) 5,
'studio_usage' => 'tests',
'otherpeople_req' => '',
'special_req' => '',
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2017-02-20T16:27:15+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2017-02-20T16:32:08+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'engineer' => object(App\Model\Entity\Engineer) {
'id' => (int) 2,
'user_id' => (int) 18,
'eng_firstname' => 'test',
'eng_lastname' => 'test',
'eng_email' => '[email protected]',
'eng_phoneno' => (int) 256,
'eng_status' => 'staff',
'rate' => (float) 51,
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2016-10-11T09:27:09+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2016-10-11T09:27:09+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Engineers'
},
'studio' => object(App\Model\Entity\Studio) {
'id' => (int) 2,
'name' => 'Studio B',
'description' => 'Studio B',
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2016-10-11T00:04:28+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2016-10-11T00:04:28+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Studios'
},
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Sessions'
},
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [
'amount' => true
],
'[original]' => [
'amount' => (float) 726.95
],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Bookings'
}
$ 예약 기록 (예 :'debug ($ booking) ') 중 하나를 디버깅하여 여기에 결과를 게시하십시오. – arilia
디버그를 시도했습니다.)하지만 그것은 내 컨트롤러에 그 변수가 없기 때문에 아마 아무것도주지 못했습니다. $ bookingsConfirmed의 디버그는 제가 OP에 추가 한 의견을주었습니다. Bookings.amount는 십진 유형을 사용하여 표시됩니다. – mistaq
foreach 루프 내에 해당 변수가 있습니다. – arilia