Ejemplo n.º 1
0
$param1 = 10;
$param2 = 11;
$data1->prepare($strsql, array(&$param1, &$param2));
$data1->execute();
print_array($data1->data_key_assoc('id'));
// Turn off auto commit
$data1->auto_commit(false);
// Insert two test Rows
$strsql2 = 'insert into contacts (id, first_name, last_name, city, state) values (?, ?, ?, ?, ?)';
$params = array(10, 'bob', 'bobson', 'toowalk', 'MN');
$data1->prepare($strsql2);
$data1->execute($params);
$params = array(11, 'john', 'smith', 'Racine', 'WI');
$data1->prepare($strsql2);
$data1->execute($params);
$data1->commit();
print_sub_header('Inserted two rows and committed. They should exist...');
$data1->prepare($strsql);
$data1->execute(array(&$param1, &$param2));
$data = $data1->data_key_assoc('id');
print_array($data);
print_sub_header('Deleted the two rows that were added then rolled back.');
$strsql3 = 'delete from contacts where id IN (?, ?)';
$data1->prepare($strsql3);
$data1->execute(array(&$param1, &$param2));
$data1->rollback();
//$data1->commit();
print_sub_header('They should still be there...');
$data1->prepare($strsql);
$data1->execute(array(&$param1, &$param2));
$data = $data1->data_key_assoc('id');