리눅스/php

php 쿼리로 호출해보기.

Rohin 2021. 1. 6. 11:32
반응형

<?php

define("DB_HOST", "IP주소");

define("DB_USER", "호출할DB유저명");

define("DB_PASSWORD", "유저패스워드");

define("DB_NAME", "DB명");

define("DB_PORT", "DB 포트");

 

$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DB_PORT);

$query = "호출해볼 쿼리명 적어넣기";

ex) $query = "CALL SP_STATS_all ('ilsan', '2020-01-01', '2020-12-10', '', '', 'Y', 'Y', 'Y', 'Y', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')";

 

if ($result = mysqli_query($conn, $query)) {

    while ($row = mysqli_fetch_row($result)) {

        echo $row[0] . "<br>" . $row[1] . "<br>" . $row[2] . "<br>" . $row[3] . "<br>" . $row[4] . "<br>" . $row[5] . "<br>" . $row[6] . "<br>" . $row[7] . "<br>";

    }

}

 

mysqli_close($conn);

?>