Create Database
SwartzDB allows you to create a new database file using the create function. This function generates an empty .sdb file in the specified storage directory.
Using the create Function
To create a new database, use the following method with your SwartzDB instance:
$sdb->create("mydatabase");
How It Works:
"mydatabase"is the name of the database you want to create.- This will generate a file called
mydatabase.sdbinside the storage folder (/SwartzDB/storage/by default or your custom path if set). - If the storage directory does not exist, SwartzDB will attempt to create it.
Enabling Error Reporting
By default, the function suppresses errors. However, if you want to enable error reporting for debugging, pass true as the second argument:
$sdb->create("mydatabase", true);
warning
Error reporting is a feature built only for development process, as it passes the error to the console of the browser. Do not use it in deployment.
By following these steps, you can create and manage databases efficiently using SwartzDB.