Herewith I need to pass a variable value instead of column name of mysql table. At the beginning I got that variable value from select query return as
public function getSiteGrading($site)
{
$siteGrading = DB::table('sites')
->select('siteGrading')
->where('code',$site)
->get();
return $siteGrading;
}
Then I need to use that return variable value '$siteG' as a column name for another select query as
public function getItemStatus($itemCode)
{
$ordSite = Auth::user()->name;
$siteG = $this->getSiteGrading($ordSite);
// dd($siteG);
$mandatory_count = DB::table('item_statuses')
->select('itemCode')
->where('itemCode',$itemCode)
->where($siteG,'M')
->get();
// dd($mandatory_count);
return $mandatory_count;
}
Finally from the 'getItemStatus' function, I got below error saying wrong column name. 'SQLSTATE[42S22]: Column not found: 1054 Unknown column '[{"siteGrading":"s57201"}]' in 'where clause' (SQL: select itemCode
from item_statuses
where itemCode
= AM0201 and [{"siteGrading":"s57201"}]
= M)'
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire