-3

I ve got table in data base called invoices and columns automonth and autoyear with values. I don't know why this function returns empty array. I want to get rows with automonth value and autoyear value. Please help me.

$autoyear = date('Y');
$automonth = date('m');

$autonumber = DB::table("invoices as invoices")
    ->where('automonth', '=', '$automonth')
    ->where('autoyear', '=', '$autoyear') 
    ->get();
Piotrek
  • 149
  • 1
  • 4
  • 14

2 Answers2

1

you pass your variable in a wrong way:

$autonumber = DB::table("invoices as invoices")
    ->where('automonth', '=', $automonth)
    ->where('autoyear', '=', $autoyear) 
    ->get();

there is no need of '' when you pass the your variable names ...

OMR
  • 11,736
  • 5
  • 20
  • 35
1

remove quotes from $automonth and $autoyear :

$autonumber = DB::table("invoices as invoices")
    ->where('automonth', '=', $automonth)
    ->where('autoyear', '=', $autoyear) 
    ->get();
Ahmed Atoui
  • 1,506
  • 1
  • 8
  • 11