PHP sqlsrv query to database

后端 未结 4 2174
独厮守ぢ
独厮守ぢ 2021-02-13 18:10

I am migrated from MySQL to MS SQL Server, and trying to fetch all data from the routines table. I am connected but unsure how to fetch data with sqlsrv. This is how far I have

4条回答
  •  野的像风
    2021-02-13 18:36

    After you've successfully executed the query with sqlsrv_query you can fetch the results, e.g., by using sqlsrv_fetch_array:

    $result = sqlsrv_query($db->db_conn, "SELECT * FROM routines");
    if($result === false) {
        die( print_r( sqlsrv_errors(), true) );
    }
    
    while( $row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC) ) {
        echo $row['column1'].", ".$row['column2']."
    "; }

提交回复
热议问题