I am using PDO to get data from database. Nevertheless, when fetching data from database, if I use PDO::FETCH_ASSOC
it shows null
, but when using PDO::FETCH_NUM
or PDO::FETCH_BOTH
the numeric array has the data I need, but the associative array doesn’t. Why is that? Thanks
Code:
$stmt =
Connection::connect()
->prepare("SELECT *
FROM usuarios LEFT OUTER JOIN tbl_company ON usuarios.fk_company = tbl_company.id
WHERE usuarios.usuario = :item");
$stmt->bindParam(":item", $value, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetch();
Result: