I have SQL query in Laravel as such:
$PDO = DB::connection('mysql')->getPdo();
$sql = <<< SQLEND
SELECT EXISTS(SELECT * FROM tpalautus where student_id = $id AND hnro=$num) ;
SQLEND;
$allsql = $PDO->prepare($sql);
$allsql->execute();
$result = $allsql->fetchAll((\PDO::FETCH_OBJ));
dd($result);
dd shows me that:
array:1 [▼
0 => {#345 ▼
+"EXISTS(SELECT * FROM tpalautus where student_id = 4 AND hnro=1)": 0
}
]
My problem is that I wish to do if statement on this result, check if it is 0 or 1, how do I do this ? I find it quite difficult to select this since objects key is SQL query statement. For example $result[0]->KEY_HERE is not working with such a long string Query statement.
Can I somehow choose what I want as that Key name? Or any other way?