<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
maxdb_query($link, "CREATE TABLE temp.mycity LIKE hotel.city");
/* Prepare an insert statement */
$query = "INSERT INTO temp.mycity (zip, name, state) VALUES (?,?,?)";
$stmt = maxdb_prepare($link, $query);
maxdb_stmt_bind_param($stmt, "sss", $val1, $val2, $val3);
$val1 = '11111';
$val2 = 'Georgetown';
$val3 = 'NY';
/* Execute the statement */
maxdb_stmt_execute($stmt);
$val1 = '22222';
$val2 = 'Hubbatown';
$val3 = 'CA';
/* Execute the statement */
maxdb_stmt_execute($stmt);
/* close statement */
maxdb_stmt_close($stmt);
/* retrieve all rows from myCity */
$query = "SELECT zip, name, state FROM temp.mycity";
if ($result = maxdb_query($link, $query)) {
while ($row = maxdb_fetch_row($result)) {
printf("%s (%s,%s)\n", $row[0], $row[1], $row[2]);
}
/* free result set */
maxdb_free_result($result);
}
/* remove table */
maxdb_query($link, "DROP TABLE temp.mycity");
/* close connection */
maxdb_close($link);
?>