kareems
09-16-2009, 08:37 PM
I am attempting to execute some queries on two different db2 databases, as follows (connections work fine):
$brands = array("Sample");
$sql = "SELECT * FROM sample_records WHERE brand=?";
$stmt = db2_prepare($dbconn2, $sql);
$brand_sql = "SELECT id FROM brands WHERE brand=? LIMIT 1";
$brand_stmt = db2_prepare($dbconn, $brand_sql);
$type_sql = "SELECT id FROM graphic_types WHERE graphic_type=? LIMIT 1";
$type_stmt = db2_prepare($dbconn, $type_sql);
if ($stmt) {
foreach($brands as $brand) {
//get all records for brand from old database
$result = db2_execute($stmt, array($brand));
//get brand id
if ($brand_stmt) {
$brand_result = db2_execute($brand_stmt, array($brand));
$brand_row = db2_fetch_array($brand_stmt);
$brand_id = $brand_row[0];
}
while ($row = db2_fetch_array($stmt)) {
//get type id
$type_id=$row[4];
$type_result = $db2_execute($type_stmt, array($type_id));
$type_row = db2_fetch_array($type_stmt);
//check if graphic type exists
if ($type_row == false) {
//graphic type doesn't exist, add it
$graphic_insert_stmt = db2_prepare($dbconn, "INSERT INTO graphic_types (graphic_type) VALUES (?)");
db2_execute($graphic_insert_stmt, array($type_id));
}
}
}
} else echo "false!";
?>
The errors I get are as follows:
Warning: db2_execute() [function.db2-execute]: Describe Param Failed in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 21
Warning: db2_execute() [function.db2-execute]: Binding Error in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 21
Warning: db2_execute() [function.db2-execute]: Describe Param Failed in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 25
Warning: db2_execute() [function.db2-execute]: Binding Error in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 25
Warning: db2_fetch_array() [function.db2-fetch-array]: Column information cannot be retrieved in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 26
Warning: db2_fetch_array() [function.db2-fetch-array]: Column information cannot be retrieved in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 29
Any insight anyone can offer would be greatly appreciated.
I have also tried using the db2_bind_param() function, with the same problem.
Thanks in advance.
$brands = array("Sample");
$sql = "SELECT * FROM sample_records WHERE brand=?";
$stmt = db2_prepare($dbconn2, $sql);
$brand_sql = "SELECT id FROM brands WHERE brand=? LIMIT 1";
$brand_stmt = db2_prepare($dbconn, $brand_sql);
$type_sql = "SELECT id FROM graphic_types WHERE graphic_type=? LIMIT 1";
$type_stmt = db2_prepare($dbconn, $type_sql);
if ($stmt) {
foreach($brands as $brand) {
//get all records for brand from old database
$result = db2_execute($stmt, array($brand));
//get brand id
if ($brand_stmt) {
$brand_result = db2_execute($brand_stmt, array($brand));
$brand_row = db2_fetch_array($brand_stmt);
$brand_id = $brand_row[0];
}
while ($row = db2_fetch_array($stmt)) {
//get type id
$type_id=$row[4];
$type_result = $db2_execute($type_stmt, array($type_id));
$type_row = db2_fetch_array($type_stmt);
//check if graphic type exists
if ($type_row == false) {
//graphic type doesn't exist, add it
$graphic_insert_stmt = db2_prepare($dbconn, "INSERT INTO graphic_types (graphic_type) VALUES (?)");
db2_execute($graphic_insert_stmt, array($type_id));
}
}
}
} else echo "false!";
?>
The errors I get are as follows:
Warning: db2_execute() [function.db2-execute]: Describe Param Failed in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 21
Warning: db2_execute() [function.db2-execute]: Binding Error in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 21
Warning: db2_execute() [function.db2-execute]: Describe Param Failed in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 25
Warning: db2_execute() [function.db2-execute]: Binding Error in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 25
Warning: db2_fetch_array() [function.db2-fetch-array]: Column information cannot be retrieved in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 26
Warning: db2_fetch_array() [function.db2-fetch-array]: Column information cannot be retrieved in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\migrate_data.php on line 29
Any insight anyone can offer would be greatly appreciated.
I have also tried using the db2_bind_param() function, with the same problem.
Thanks in advance.