-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
  • 151
  • 3
  • 12

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
  • 10,491
  • 5
  • 12
  • 29
1

remove quotes from $automonth and $autoyear :

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