Example #1
0
 /**
  * create / drop
  */
 public function testCreateTable()
 {
     // if table does somehow exist, drop it
     try {
         Model::dropTable(self::$table1);
     } catch (Exception $e) {
         die("ERR: " . $e);
     }
     try {
         Model::createTable(self::$table1, array('id' => array('type' => 'int', 'length' => '11', 'not_null' => true, 'key' => 'PRI', 'auto_increment' => true), 'name' => array('type' => 'varchar', 'length' => '255', 'default' => null), 'email' => array('type' => 'varchar', 'length' => '255', 'key' => 'UNI'), 'price' => array('type' => 'double', 'length' => '8,2'), 'description' => array('type' => 'text'), 'created' => array('type' => 'int', 'length' => '10'), 'modified' => array('type' => 'int', 'length' => '10')));
     } catch (Exception $e) {
         die("ERR: " . $e);
     }
 }
Example #2
0
<?php

use Onephile\Model;
try {
    Model::createTable('model_test_1', array('id' => array('type' => 'int', 'length' => '11', 'not_null' => true, 'key' => 'PRI', 'auto_increment' => true), 'name' => array('type' => 'varchar', 'length' => '255', 'default' => null), 'email' => array('type' => 'varchar', 'length' => '255', 'key' => 'UNI'), 'price' => array('type' => 'double', 'length' => '8,2'), 'description' => array('type' => 'text'), 'created' => array('type' => 'int', 'length' => '10'), 'modified' => array('type' => 'int', 'length' => '10')));
} catch (Exception $e) {
    die("Error: " . $e);
}
echo 'Success!';