I'm having some problems with some SQL in Laravel in a controller.
Here's what i have :
public function getKeyword()
{
$date = strftime("%Y-%m-%d");
echo ($date);
$keyword = DB::table('demo_question_keyword')
->select('keyword')
->orderBy('date_from', 'desc')
->having('date_from', '>=', $date)
->limit(1)
->get();
echo ($keyword);
}
This prints the date correctly, but it seems like $keyword does not retrieve what i want correctly. I also tried to make it more simple, using $keyword = DB::select('select keyword from demo_question_keyword'); but i'm getting the same error.
I also tried with PDO in a different way :
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('localhost::3306;dbname=Agora', 'Adonis', 'Agoraroot', $pdo_options);
$stmt = $bdd->prepare('SELECT keyword FROM demo_question_keyword ORDER BY id_question DESC LIMIT 1');
$stmt->execute();
$row = $stmt->fetch;
echo $row['keyword'];
but again, same error.
This is the error i'm always getting :
local.ERROR: exception 'ErrorException' with message 'Undefined property: stdClass::$exactLocation'
And this is the line that the error is directing to :
$campaign->exact_location = $jsonBody->exactLocation;
But it seems weird to me because $exactLocation has nothing to do with what i'm doing in my controller.
Thank you for taking the time to try to help me.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire