Advertisements

maybe_create_table

Definition:
function maybe_create_table($table_name, $create_ddl) {}

Parameters

  • string $table_name: Database table name to create.
  • string $create_ddl: SQL statement to create table.

Return values

returns:If table already exists or was created by function.

Source code

function maybe_create_table($table_name, $create_ddl) {

	global $wpdb;

	if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )

		return true;

	//didn't find it try to create it.

	$q = $wpdb->query($create_ddl);

	// we cannot directly tell that whether this succeeded!

	if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )

		return true;

	return false;

}

9996

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: