EUNJIHA / Dev-Tips

👩🏻‍💻Develop 중에 해결한 문제들 issue 작성

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP, MySQL 출력 방식

EUNJIHA opened this issue · comments

commented
function showBands(){
    
    $pdo = pdoSqlConnect();
    $query = "select b.bandKey, b.bandPicURL
                     from band b;";

    $st = $pdo->prepare($query);

    $st->execute();

    // $st->execute([$postKey]);     -->  query문에 ? 넣고 변수로 입력 받고 싶을 때

    $st->setFetchMode(PDO::FETCH_ASSOC);
    $res = $st->fetchAll();

    $st = null;
    $pdo = null;

    return $res;
    // return $res[0];
}
commented

Query 결과
image

commented
print_r($res)

image

commented
return $res[0]

image

return $res

image