请帮我处理laravel 5中的格式查询。我是使用laravel 5的初学者,我只是搜索得出这个查询,但现在我收到错误我不知道在哪里以及为什么?我认为我的错误仅在于语法?
这是我的代码:
$date = date("Y-m-d", strtotime($request->datepicker2));
$products = DB::table('shipping_table')
->select('products.product_name', 'products.price', 'Sum(shipping_products.quantity) AS qtysold', 'shipping_table.sold_date')
->join('shipping_products','shipping_table.shipping_id', '=', 'shipping_products.shipping_id')
->join('products','products.product_id', '=', 'shipping_products.product_id')
->where([['DATE(shipping_table.sold_date)', '=',$date], ['shipping_table.shipping_status', '=' ,1]])
->groupBy('products.product_name')
->paginate(8);
有什么建议吗?我打印错误,它说:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'DATE(shipping_table.sold_date)' in 'where clause'
答案 0 :(得分:3)
此行中有额外的起始void VerticalSearch(char** puzzleArray, searchedWord* word) {
int len = word->wordLength;
char **tmp = puzzleArray;
char *ptr = &puzzleArray[0][0];
string s;
for (int i = 0; i < 15; i++) {
**tmp = *ptr;
s = "";
for (int k = 0; k < 15; k++)
{
s += **tmp;
(tmp)++;
}
cout << s << endl;
ptr++;
}
}
: -
[
需要(使用->where([['DATE(shipping_table.sold_date)', '=',$date, ['shipping_table.shipping_status', '=' ,1]])
来使用DB::raw()
): -
mysql functions
注意: -
关于您得到的错误($date = date("Y-m-d", strtotime($request->datepicker2));
$products = DB::table('shipping_table')
->select('products.product_name', 'products.price', DB::raw("Sum(shipping_products.quantity) as qtysold"), 'shipping_table.sold_date')
->join('shipping_products','shipping_table.shipping_id', '=', 'shipping_products.shipping_id')
->join('products','products.product_id', '=', 'shipping_products.product_id')
->where([[DB::raw("date(shipping_table.sold_date)"),$date], ['shipping_table.shipping_status', '=' ,1]])
->groupBy('products.product_name')
->paginate(8);
),请检查此答案并做相应的操作: -