How to create a Database and Table?
<?php
# Including MySQLm [See https://github.com/AtjonTV/MySQLm/wiki/1.-Getting-Started or https://atjontv.github.io/MySQLm/starting.html]
include 'https://raw.githubusercontent.com/AtjonTV/MySQLm/dev-1.5d/src/MySQLm.php';
# Creating MySQLm Object with direct connect [ See https://github.com/AtjonTV/MySQLm/wiki/2-Connecting or https://atjontv.github.io/MySQLm/db-connecting.html]
$msql = new MySQLm("database-server.com", 3306, "myusername", "userspassword", "databasename", "charset");
/* For this showcase/tutorial/wiki, i will use the w3schools php&&sql tutorial
If you want to see the original you can visit:
https://www.w3schools.com/php/php_mysql_create_table.asp
*/
// First we will create a database on the server, even if we are connected to one, we want to create another
# Easiest way:
$msql->executeCreate("DATABASE ShowCaseDatabase");
// As seen in tutorial 3 [https://github.com/AtjonTV/MySQLm/wiki/3-Chaning-Database or https://atjontv.github.io/MySQLm/db-changing.html] we need to use it now.
$msql->executeUse("ShowCaseDatabase");
// Now we need a table to store stuff
// The easyest way to do it with MySQLm is to use executeCreate
# To make it more overviewable, lets make a query variable:
$query = "TABLE MyGuests (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, ".
"firstname VARCHAR(30) NOT NULL, ".
"lastname VARCHAR(30) NOT NULL, ".
"email VARCHAR(50), ".
"reg_date TIMESTAMP)";
# Now, execute the Create (The Create keyword gets automaticly set before the query we give)
$msql->executeCreate($query);
$msql->dispose("acc", "x");
?>