mysqli::query
(mysqli_query) 데이터베이스에서 쿼리를 수행합니다
query() / mysqli_query() 함수는 데이터베이스에서 쿼리를 실행합니다.
데이터베이스에서 쿼리를 수행하십시오.
<? php
$ mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "my_db" ) ;
// 연결을 확인합니다
if ( $ mysqli- > connect_errno ) {
Echo "MySQL에 연결하지 못했습니다 :" . $ mysqli- > connect_error ;
출구 ( ) ;
}
// 쿼리를 실행합니다
if ( $ result = $ mysqli- > query ( "select * from persons" ) ) {
Echo "반환 된 행은 다음과 같습니다." . $ result- > num_rows ;
// 결과 세트를 릴리스합니다
$ result- > free_result ( ) ;
}
$ mysqli- > close ( ) ;
?>
데이터베이스에서 쿼리를 수행하십시오.
<? php
$ con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ;
if ( mysqli_connect_errno ( ) ) {
Echo "MySQL에 연결하지 못했습니다 :" . mysqli_connect_error ( ) ;
출구 ( ) ;
}
// 쿼리를 실행합니다
if ( $ result = mysqli_query ( $ con , "select * from persons" ) ) {
Echo "반환 된 행은 다음과 같습니다." . mysqli_num_rows ( $ result ) ;
// 결과 세트를 릴리스합니다
mysqli_free_result ( $ result ) ;
}
mysqli_close ( $ con ) ;
?>