php - Select one value of one colum of an array obtained with pdo -
i have following code :
$foo = $bdd->prepare($qry); $foo->execute(); $result = $foo->fetchall();
in $qry
, have select
join
between tables beatles b
et status s
(on columns status_id
), such result following :
code :
b.id b.firstname b.lastname b.status_id s.status_id s.status 0 john lennon 0 0 mort 1 paul mccartney 1 1 vivant 2 ringo starr 1 1 vivant 3 george harrison 0 0 mort
(the first line columns' names in tables, isn't inside result of query)
i want select in php s.status
of ringo starr, instance. how can ?
thanks
if want retrieve value of status ringo starr, need values of other fields within page, (assuming array has come indexed id), access $result[2]['status']
. otherwise, change select statement select values of id
, status
.
as side note, in select statement you'll need give aliases potentially b.status_id
, s.status_id
; when join, column names taken , table names ignored in terms of returned - b.status_id b_status_id, s.status_id s_status_id
make sure got correct values both of these. may have done of course - looked though might have not, judging column names gave.
Comments
Post a Comment