<?php // ------------------- // // --- Idiorm Demo --- // // ------------------- // // Note: This is just about the simplest database-driven webapp it's possible to create // and is designed only for the purpose of demonstrating how Idiorm works. // In case it's not obvious: this is not the correct way to build web applications! // Require the idiorm file require_once "Idiorm.php"; // Connect to the demo database file ORM::configure('sqlite:./demo.sqlite'); // This grabs the raw database connection from the ORM // class and creates the table if it doesn't already exist. // Wouldn't normally be needed if the table is already there. $db = ORM::getDb(); $db->exec("\n CREATE TABLE IF NOT EXISTS contact (\n id INTEGER PRIMARY KEY, \n name TEXT, \n email TEXT \n );"); // Handle POST submission if (!empty($_POST)) { // Create a new contact object $contact = ORM::forTable('contact')->create(); // SHOULD BE MORE ERROR CHECKING HERE! // Set the properties of the object $contact->name = $_POST['name']; $contact->email = $_POST['email']; // Save the object to the database $contact->save(); // Redirect to self. header('Location: ' . basename(__FILE__)); exit; }
<?php include __DIR__ . '/../bootstrap.php'; return ["paths" => ["migrations" => __DIR__ . "/../dataase/migrations/", "seeds" => __DIR__ . "/../database/migrations/"], "environments" => ["default_migration_table" => "phinxlog", "default_database" => "development", "development" => ['connection' => \ORM::getDb(), 'name' => 'development'], "qa" => ['connection' => \ORM::getDb(), 'name' => 'qa'], "production" => ['connection' => \ORM::getDb(), 'name' => 'production']]];