Switch to standard view 
  Sybase logo
 
 
 



Description:
sasql_fetch_object() returns one row of the result set as an object. Each property name matches one of the result set's column name. It returns FALSE if there are no more rows in the result set.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
 
    #*********************************************************************     
    # Description:
    # sasql_fetch_object() returns one row of the result set as an object.
    # Each property name matches one of the result set's column name.
    # It returns FALSE if there are no more rows in the result set.
    #
    #*********************************************************************     
 
    # Connect using the default user ID and password
    $conn = sasql_connect ( "UID=DBA;PWD=sql" ) ;
 
    if ( ! $conn ) {
        echo "sasql_connect failed \n " ;
    } else {
        $result = sasql_query ( $conn , "SELECT * FROM Customers" ) ;
 
        if ( ! $result ) {
          echo "sasql_query failed!" ;
        } else {
          $num_cols = sasql_field_count ( $conn ) ;
          $num_rows = sasql_num_rows ( $result ) ;
 
          echo "Num of rows = $num_rows<br> \n " ;
          echo "Num of cols = $num_cols<br> \n " ;
          echo "<br> \n " ;
 
          $cur_row = 0 ;
          $cur_col = 0 ;
         
          # Fetch object
          while ( ( $row = sasql_fetch_object ( $result ) ) ) {
              echo "($cur_row): =========================== <br> \n " ;
              #Print the key and value of each object
              while ( list ( $key , $val ) = each ( $row ) ) {
                echo "$key : $val \n " ;
                $cur_col ++;
              }
              echo "<br> \n " ;
              $cur_row ++;
          }
          # Free result set
          sasql_free_result ( $result ) ;
        }
        # Close connection
       sasql_close ( $conn ) ;
        echo "<br> \n " ;
    }
 
?>

 

Copyright 1994-2009 iAnywhere Solutions, Inc. All rights reserved. This sample code is provided AS IS, without warranty or liability of any kind.
You may use, reproduce, modify and distribute this sample code without limitation, on the condition that you retain the foregoing copyright notice and disclaimer as to the original iAnywhere code.



Back to Top
© Copyright 2010, Sybase Inc.