Page 1 of 1

transactions and their infinitely reflective mirrors

Posted: Wed Jul 28, 2004 3:53 pm
by brandan
i'm getting an annoying error that i can find no information on. here are the two scripts that it occurs during:

Code: Select all

function sqlite_drop_tables($database) {
	
	print("* Dropping all tables: ");
	
	// *** start transaction ***
	$transaction = "begin;\n";
			
	// *** get the list of tables ***
	$table = sqlite_array_query($database, "select * from sqlite_master where type='table'", SQLITE_ASSOC);
	if (is_array($table)) {
			
		foreach($table as $this_table) {
			
			// *** drop this table ***
			$transaction .= sprintf("drop table %s;\n", $this_table['name']);
		}
	}
			
	// *** end and commit transaction ***
	if (sqlite_query($database, sprintf("%scommit;\n", $transaction))) {
		print("Okay\n");	
	}

	else {
		print("Failed\n");
		/* die($php_errormsg . "\n"); */
	}
}

Code: Select all

function sqlite_schema_setup($database, $path) {

	printf("* Building database schema from %s: ", $path);

	if ($setup_transaction = file_get_contents($path) and sqlite_query($database, $setup_transaction)) {
		print("Okay\n");
	}

	else {
		print("Failed\n");
		die($php_errormsg . "\n");
	}
}
the error is 'cannot start a transaction within a transaction'. somebody aid me. please.