transactions and their infinitely reflective mirrors

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brandan
Forum Commoner
Posts: 37
Joined: Sat Jul 24, 2004 6:39 pm
Location: fort smith, ar

transactions and their infinitely reflective mirrors

Post 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.
Post Reply