我使用CakePHP 3.4調用成員函數的格式()布爾CakePHP中3
我收到遊客使用
$profile_visit_logs = $this->Users->LogProfileVisits->find()
->where(['user_id' => $user->id]);
$profile_visit_logs->select([
'total_count' => $profile_visit_logs->func()->count('id'),
'unique_count' => $profile_visit_logs->func()->count('DISTINCT `ip_address`'),
'visit_date' => 'MONTH(created)'
])
->group('visit_date')
->limit(10);
從LogProfileVisits
表計數,但這個被賦予致命錯誤的
Error: Call to a member function format() on boolean
File /path_to_app/vendor/cakephp/chronos/src/Traits/FrozenTimeTrait.php
Line: 161
同樣是工作的罰款DATE(created)
和YEAR(created)
錯誤日誌
2017-06-02 12:25:45 Warning: Warning (2): DateTimeImmutable::modify() [<a href='http://php.net/datetimeimmutable.modify'>datetimeimmutable.modify</a>]: Failed to parse time string (5) at position 0 (5): Unexpected character in [/path_to_app/vendor/cakephp/chronos/src/Traits/FrozenTimeTrait.php, line 160]
Request URL: /dashboard/profile/ajax_profile_performance
Referer URL: http://example.com/dashboard
Client IP: client_ip
Trace:
Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 153
DateTimeImmutable::modify() - [internal], line ??
Cake\Chronos\Date::modify() - ROOT/vendor/cakephp/chronos/src/Traits/FrozenTimeTrait.php, line 160
Cake\Database\Type\DateTimeType::toPHP() - CORE/src/Database/Type/DateTimeType.php, line 139
Cake\Database\Type\DateType::toPHP() - CORE/src/Database/Type/DateType.php, line 90
Cake\Database\FieldTypeConverter::__invoke() - CORE/src/Database/FieldTypeConverter.php, line 78
Cake\Database\Statement\CallbackStatement::fetch() - CORE/src/Database/Statement/CallbackStatement.php, line 59
Cake\ORM\ResultSet::_fetchResult() - CORE/src/ORM/ResultSet.php, line 484
Cake\ORM\ResultSet::valid() - CORE/src/ORM/ResultSet.php, line 276
App\Controller\Dashboard\ProfileController::ajaxProfilePerformance() - APP/Controller/Dashboard/ProfileController.php, line 113
Cake\Controller\Controller::invokeAction() - CORE/src/Controller/Controller.php, line 440
Cake\Http\ActionDispatcher::_invoke() - CORE/src/Http/ActionDispatcher.php, line 119
Cake\Http\ActionDispatcher::dispatch() - CORE/src/Http/ActionDispatcher.php, line 93
Cake\Http\BaseApplication::__invoke() - CORE/src/Http/BaseApplication.php, line 78
Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
Cake\Routing\Middleware\RoutingMiddleware::__invoke() - CORE/src/Routing/Middleware/RoutingMiddleware.php, line 59
Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
Cake\Routing\Middleware\AssetMiddleware::__invoke() - CORE/src/Routing/Middleware/AssetMiddleware.php, line 88
Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
Cake\Error\Middleware\ErrorHandlerMiddleware::__invoke() - CORE/src/Error/Middleware/ErrorHandlerMiddleware.php, line 92
Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
Cake\Http\Runner::run() - CORE/src/Http/Runner.php, line 51
Cake\Http\Server::run() - CORE/src/Http/Server.php, line 80
[main] - ROOT/webroot/index.php, line 37
2017-06-02 12:25:45 Error: Fatal Error (1): Call to a member function format() on boolean in [/path_to_app/vendor/cakephp/chronos/src/Traits/FrozenTimeTrait.php, line 161]
Request URL: /dashboard/profile/ajax_profile_performance
Referer URL: http://profplus.in/dashboard
Client IP: client_ip
Trace:
Cake\Error\BaseErrorHandler::handleFatalError() - CORE/src/Error/BaseErrorHandler.php, line 223
Cake\Error\BaseErrorHandler::Cake\Error\{closure}() - CORE/src/Error/BaseErrorHandler.php, line 105
[main] - [internal], line ??
2017-06-02 12:25:46 Warning: Headers already sent in /path_to_app/vendor/cakephp/cakephp/src/Error/Debugger.php:822
2017-06-02 12:25:46 Error: [Cake\Error\FatalErrorException] Call to a member function format() on boolean in /path_to_app/vendor/cakephp/chronos/src/Traits/FrozenTimeTrait.php on line 161
Request URL: /dashboard/profile/ajax_profile_performance
Referer URL: http://example.com/dashboard
Client IP: client_ip
Stack Trace:
#0 /path_to_app/vendor/cakephp/cakephp/src/Error/BaseErrorHandler.php(105): Cake\Error\BaseErrorHandler->handleFatalError(1, 'Call to a membe...', '/home/thebornen...', 161)
#1 [internal function]: Cake\Error\BaseErrorHandler->Cake\Error\{closure}()
#2 {main}
無論何時收到錯誤,請始終發佈** _complete_錯誤**,即**包括_full_ stacktrace **(理想情況下,以可正常讀取的方式從日誌中複製)!'visit_date'可能是一個現有的(日期 - 時間型)表格列? – ndm
@ndm更新錯誤日誌的問題 –
那麼'visit_date'是一個現有的列呢? – ndm