0
PHP에서 객체의 각 행을 각각로드 한 다음 배열에 모두 추가하고 배열을 반환하여 java 객체 등으로 변환 할 수있게하려고합니다.PHP 행의 객체 배열 반환하기
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
$dbhost = "localhost";
$dbname = "Example";
$dbuser = "Example";
$dbpass = "Example";
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
$objectArray = array();
$stmt = $conn->prepare("SELECT * FROM Table");
while ($row = $stmt->fetch())
{
#add all columns on this row to an object and add to array
}
$stmt->execute();
if(!$stmt)
print_r($dbh->errorInfo());
?>