4 Create - AtjonTV/MySQLm Wiki

Create

Function executeCreate():

The executeCreate method can be used to create Databases and Tables.

The function requieres the full SQL-Query without the CREATE keyword.

This method is SQL-Injection save by default. To disable SQL-Injection-Prevention in order to use escapecharacters like ', you need to supply a true boolean value.

Structure:

  1. SQL-Query

Database Example:

// Example with escapecharacters denyed
$msql->executeCreate('DATABASE MyApp');
$msql->executeCreate('DATABASE MyApp', false);

// Example with escapecharacters allowed
$msql->executeCreate('DATABASE MyApp', true);

SQL-Query:

CREATE DATABASE MyApp;

Table Example:

// Example with escapecharacters denyed
$msql->executeCreate('TABLE Users (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL, email VARCHAR(50))');
$msql->executeCreate('TABLE Users (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL, email VARCHAR(50))', false);

// Example with escapecharacters allowed
$msql->executeCreate('TABLE Users (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL, email VARCHAR(50))', true);

SQL-Query:

CREATE TABLE Users (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL, email VARCHAR(50));