本篇內(nèi)容主要講解“l(fā)aravel用clickhouse查詢出現(xiàn)“Missing columns”如何解決”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“l(fā)aravel用clickhouse查詢出現(xiàn)“Missing columns”如何解決”吧!
專注于為中小企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計、成都外貿(mào)網(wǎng)站建設(shè)服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)雙鴨山免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千余家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
使用 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);
}
當(dāng)多個條件查詢時,$where 數(shù)組在 sql 中會被當(dāng)成一個字段,從而導(dǎo)致 DB:: Exception: Missing columns: ‘2022-09-27 13:00:49’ ‘2022-09-27 16:00:49’ while processing query 的錯誤。
這樣優(yōu)化:
$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);
}
才能正確查詢。
多提一句:在命令行查詢時,參數(shù)值使用單引號,使用雙引號時,參數(shù)值也會被當(dāng)成一個字段:
正確操作是:
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;
到此,相信大家對“l(fā)aravel用clickhouse查詢出現(xiàn)“Missing columns”如何解決”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
當(dāng)前題目:laravel用clickhouse查詢出現(xiàn)“Missingcolumns”如何解決
本文鏈接:http://chinadenli.net/article36/gedhsg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)、微信公眾號、網(wǎng)站營銷、網(wǎng)站收錄、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)