Add a SQL Database Page

You can add a page that maps to a table on a SQL Database. Note that most of the API is identical independent of the type of database you’re using. However, while initializing you need to use a different class for each type.

  • You need to pass a unique string ID for each page. This is mandatory
  • You also have to use setTableName to set the table which will be used. This is mandatory for each page.

Adding a MySQL Table as a page

To add a MySQL Table as a page, use the MySQLTablePage class:

<?php
require "crudkit/crudkit.php";
use CrudKit\CrudKitApp;
use CrudKit\Pages\MySQLTablePage;

$app = new CrudKitApp();

$mysql_page = new MySQLTablePage ("page_id", "username", "password", "database"); // Set a unique PAge ID too
$mysql_page->setTableName ("my_table");
// ...
// Configure the MySQL Page
// ...
$app->addPage ($mysql_page);

$app->render();
?>

The parameters you can pass are:

  • a unique page id
  • username
  • password
  • Database Name
  • server address (optional. Defaults to localhost)
  • port (optional)

Adding a SQLite Table as a page

To add a MySQL Table as a page, use the SQLiteTablePage class:

<?php
require "crudkit/crudkit.php";
use CrudKit\CrudKitApp;
use CrudKit\SQLiteTablePage;

$app = new CrudKitApp();

$sqlite_page = new SQLiteTablePage("page_id", "path/to/database.db");
$sqlite_page->setTableName ("my_table");
// ...
// Configure the MySQL Page
// ...
$app->addPage ($sqlite_page);

$app->render();
?>

The parameters you can pass are:

  • A unique page id
  • path to file

PostgreSQL Table

Coming soon.

Built by Anirudh Sanjeev. CrudKit is distributed under the MIT/X11 License.