Revision: 57122
Updated Code
at May 17, 2012 01:57 by zombree
Updated Code
$db_connection = database_connect(); $sql = "SELECT..."; //if using db2_bind_param.... //$sql = "SELECT * FROM table WHERE id = ?"; //$id = '123'; $stmt = db2_prepare($db_connection, $sql); //db2_bind_param($stmt,1,"id",DB2_PARAM_IN); $error = db2_stmt_errormsg(); if(db2_execute($stmt)){ while ($row = db2_fetch_object($stmt)){ $x = $row->x; $results[] = $row; } }else{ } function database_connect() { $db_name = ''; $usr_name = ''; $password = ''; $conn_resource = db2_connect($db_name, $usr_name, $password); if ($conn_resource) { //dd() is a drupal function. replace w/ echo() dd('Connection to database succeeded.'); return $conn_resource; } else { dd('Connection to database failed.'); dd('SQLSTATE: ' . db2_conn_error()); dd('Message: ' . db2_conn_errormsg()); } }
Revision: 57121
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 17, 2012 01:52 by zombree
Initial Code
$db_connection = database_connect(); $sql = "SELECT..."; $stmt = db2_prepare($db_connection, $sql); //db2_bind_param($stmt,1,"ids",DB2_PARAM_IN); $error = db2_stmt_errormsg(); if(db2_execute($stmt)){ while ($row = db2_fetch_object($stmt)){ $x = $row->x; $results[] = $row; } }else{ } function database_connect() { $db_name = ''; $usr_name = ''; $password = ''; $conn_resource = db2_connect($db_name, $usr_name, $password); if ($conn_resource) { //dd() is a drupal function. replace w/ echo() dd('Connection to database succeeded.'); return $conn_resource; } else { dd('Connection to database failed.'); dd('SQLSTATE: ' . db2_conn_error()); dd('Message: ' . db2_conn_errormsg()); } }
Initial URL
Initial Description
Connect to and query a db2 database using php.
Initial Title
db2 connect and query
Initial Tags
database, query
Initial Language
PHP