(PECL maxdb >= 1.0)
Binds variables to a prepared statement for result storage
bool maxdb_stmt_bind_result ( resource $stmt, mixed &$var1 [, mixed &$... ] )
Procedural style
Object oriented style
bool maxdb_stmt::bind_result ( mixed
&$var1
[, mixed &$...
] ) maxdb_stmt_bind_result() is used to associate (bind) columns in the result set to variables. When maxdb_stmt_fetch() is called to fetch data, the MaxDB client/server protocol places the data for the bound columns into the specified variables var1, ...
.
Note:
Note that all columns must be bound prior to calling maxdb_stmt_fetch(). Depending on column types bound variables can silently change to the corresponding PHP type.
A column can be bound or rebound at any time, even after a result set has been partially retrieved. The new binding takes effect the next time maxdb_stmt_fetch() is called.
Returns:
Returns TRUE
on success or FALSE
on failure.
Examples:
Object oriented style
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 | <?php $maxdb = new maxdb( "localhost" , "MONA" , "RED" , "DEMODB" ); if (maxdb_connect_errno()) { printf( "Connect failed: %s\n" , maxdb_connect_error()); exit (); } /* prepare statement */ if ( $stmt = $maxdb ->prepare( "SELECT zip, name FROM hotel.city ORDER BY name" )) { $stmt ->execute(); /* bind variables to prepared statement */ $stmt ->bind_result( $col1 , $col2 ); /* fetch values */ while ( $stmt ->fetch()) { printf( "%s %s\n" , $col1 , $col2 ); } /* close statement */ $stmt ->close(); } /* close connection */ $maxdb ->close(); ?> |
Procedural style
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 | <?php $link = maxdb_connect( "localhost" , "MONA" , "RED" , "DEMODB" ); /* check connection */ if (! $link ) { printf( "Connect failed: %s\n" , maxdb_connect_error()); exit (); } /* prepare statement */ if ( $stmt = maxdb_prepare( $link , "SELECT zip, name FROM hotel.city ORDER BY name" )) { maxdb_stmt_execute( $stmt ); /* bind variables to prepared statement */ maxdb_stmt_bind_result( $stmt , $col1 , $col2 ); /* fetch values */ while (maxdb_stmt_fetch( $stmt )) { printf( "%s %s\n" , $col1 , $col2 ); } /* close statement */ maxdb_stmt_close( $stmt ); } /* close connection */ maxdb_close( $link ); ?> |
See also:
Please login to continue.