以下由Laravel教學專欄跟大家介紹在laravel使用clickhouse查詢所引起的「DB::Exception: Missing columns」問題,希望對大家有幫助!
使用 clickhouse
尤其註意:不能這麼寫!
$where = []; if($cookieId) { $where['cookie_id'] = $cookieId; } if($host) { $where['host'] = $host; } if($uri) { $where['uri'] = $uri; } $builder = DB::connection('clickhouse') ->table((new AccessLogs)->getTable()) ->where($where); if(!empty($startTime)) { $builder->where('create_time', '>=', $startTime); } if(!empty($endTime)) { $builder->where('create_time', '<=', $endTime); }
當多個條件查詢時,$where 數組在sql 中會被當成一個字段,從而導致DB:: Exception: Missing columns: '2022-09-27 13:00:49' '2022 -09-27 16:00:49' while processing query 的錯誤。
這樣優化:
$builder = DB::connection('clickhouse') ->table((new AccessLogs)->getTable()); if(!empty($cookieId)) { $builder->where('cookie_id', $cookieId); } if(!empty($host)) { $builder->where('host', $host); } if(!empty($uri)) { $builder->where('uri', $uri); } if(!empty($startTime)) { $builder->where('create_time', '>=', $startTime); } if(!empty($endTime)) { $builder->where('create_time', '<=', $endTime); }
才能正確查詢。
多提一句:在命令列查詢時,參數值使用單引號,使用雙引號時,參數值也會被當成一個欄位:
正確運算是:
select * from access_log where create_time >= ‘2022-09-27 13:00:49’ and create_time <= ‘2022-09-27 16:00:49’ order by create_time desc limit 10;
以上是解決laravel用clickhouse查詢出現「Missing columns」問題的詳細內容。更多資訊請關注PHP中文網其他相關文章!

laravelbladeenhancesfrontendtemplatinginflatinginflationll-stackprojectsbyferingCleanSyntaxandaxandpoperfelfulfeatures.1)itallowsforeasyvariableasyvariabledisplayandControlstructures.2)bladesuportsuportsuportscreatingingingingingingingingingingangingandredreingscomponents components components components,aidinginmanagingcomplexuis.3)

laravelisidealforll-stackapplicationsduetoitselegantsyntax,complastissionecosystem和perperatedfulfeatures.1)useeloquentormforintuivelbackenddatamanipulation,butavoidn 1queryissues.2)

forremotework,iusezoomforvideOcalls,Slackformessing,trelloforprojectmanagement,and giThubForCodeCollaboration.1)Zoomisreliable forlailible forlargemeetingsbuthastimelimitsonthefreeversion.2)

remoteaccessandscreensharingworkbyestablishingasecure,real-timeconnectionbetweencomputerssusterprotococolslikerdp,vnc,orproprietarysoltions.bestpracticessinclude:1)構建thrustthroustthroustthroustthroudthrouftthroughclearcommunication,2)2)SeneruringSecuringSecurityWithStrongentStrongentStrongentStrongentscorneptermeptimptermeptimplemptymentponempts和Dat

絕對值得考慮升級到最新的Laravel版本。 1)新功能和改進,如匿名遷移,提升了開發效率和代碼質量。 2)安全性提升,修復了已知漏洞。 3)社區支持增強,提供了更多資源。 4)需評估兼容性,確保平穩升級。

在Laravel中集成Sentry和Bugsnag可以提高應用的穩定性和性能。 1.在composer.json中添加SentrySDK。 2.在config/app.php中添加Sentry服務提供者。 3.在.env文件中配置SentryDSN。 4.在App\Exceptions\Handler.php中添加Sentry錯誤報告。 5.使用Sentry捕獲並報告異常,並添加額外上下文信息。 6.在App\Exceptions\Handler.php中添加Bugsnag錯誤報告。 7.使用Bugsnag監

Laravel依然是PHP开发者的首选框架,因为它在开发体验、社区支持和生态系统上表现卓越。1)其优雅的语法和丰富的功能集,如EloquentORM和Blade模板引擎,提升了开发效率和代码可读性。2)庞大的社区提供了丰富的资源和支持。3)尽管学习曲线较陡且可能导致项目复杂性增加,但通过合理配置和优化,Laravel能显著提升应用性能。

在Laravel中構建實時聊天應用需要使用WebSocket和Pusher。具體步驟包括:1)在.env文件中配置Pusher信息;2)設置broadcasting.php文件中的廣播驅動為Pusher;3)使用LaravelEcho訂閱Pusher頻道並監聽事件;4)通過PusherAPI發送消息;5)實現私有頻道和用戶認證;6)進行性能優化和調試。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Dreamweaver CS6
視覺化網頁開發工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

WebStorm Mac版
好用的JavaScript開發工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境