Exemple #1
0
 /**
  *
  *
  */
 private function applyFetchMode($fetchMode)
 {
     //
     if ($this->_tempFetchMode != null) {
         $this->_database->errorExecute(new Exception("apply fetchMode overload"));
     }
     //
     $this->_tempFetchMode = DB::getFetchMode();
     //
     DB::setFetchMode($fetchMode);
 }
Exemple #2
0
 /**
  * Retriece linked database or default
  *
  * @return type
  */
 protected static function getDatabase()
 {
     //
     $attribute = 'Database';
     //
     if (!static::hasClassAttribute($attribute)) {
         //
         $database = Database::getDefault();
         //
         if (!$database) {
             static::error("Database not found", debug_backtrace(), 1);
         }
         //
         static::setClassAttribute($attribute, $database);
     }
     //
     return static::getClassAttribute($attribute);
 }
Exemple #3
0
<?php

//
require_once 'common.php';
//
use Javanile\SchemaDB;
//
SchemaDB\Database::getDefault()->drop('confirm');
//
class Invoice extends SchemaDB\Storable
{
    //
    public $code = '';
    //
    public $product = '<<Product>>';
}
//
class Product extends SchemaDB\Storable
{
    //
    public $id = self::PRIMARY_KEY;
    //
    public $name = '';
    //
    public $price = 0.0;
}
//
$Invoice0 = new Invoice(array('code' => 'FAT1', 'product' => array('name' => 'Product No 1', 'price' => 1.3)));
//
$Invoice0->store();
//
Exemple #4
0
<?php

//
require_once __DIR__ . '/../common.php';
//
use Javanile\SchemaDB\Database;
//
$db = new Database(['host' => $host, 'dbname' => $dbname, 'username' => $username, 'password' => $password, 'prefix' => $prefix, 'auto' => false]);
//
$db->setDebug(true);
Exemple #5
0
<?php

//
use Javanile\SchemaDB\Database;
//
if (!Database::hasDefault()) {
    //
    require_once '../common.php';
    //
    new Database(['host' => $host, 'dbname' => $name, 'username' => $user, 'password' => $pass, 'prefix' => 'Test_Join_']);
}
//
Database::getDefault()->setDebug(true);
Exemple #6
0
       public $integer_0 = 0;
       public $integer_1 = 10;
       public $integer_2 = self::TINYINT;
       public $integer_3 = self::SMALLINT;
       public $integer_4 = self::MEDIUMINT;
       public $integer_5 = self::INT; 
       public $integer_6 = self::BIGINT; /**/
    /* integer * /
       public $float_0 = .0;
       public $float_1 = 1.1;
       public $float_2 = 10.0;
       public $float_3 = self::DECIMAL;
       public $float_4 = self::NUMERIC;
       public $float_5 = self::FLOAT; 
       public $float_6 = self::DOUBLE; 
       public $float_7 = self::DOUBLE; /**/
    /* date time */
    public $datetime_0 = self::DATE;
    public $datetime_1 = self::DATETIME;
    public $datetime_2 = self::TIMESTAMP;
}
//
Fields::drop('confirm');
//
Fields::applyTable();
//
$db = Database::getDefault();
//
$db->dump();
// print-out debug info
$db->benchmark();
Exemple #7
0
<?php

//
require_once __DIR__ . '/../../common.php';
//
use Javanile\SchemaDB\Database;
//
$db = new Database(['sokect' => 'Pdo', 'host' => $host, 'dbname' => $dbname, 'username' => $username, 'password' => $password, 'prefix' => $prefix, 'adamant' => false, 'debug' => true]);
//
$db->drop('Person', 'confirm');
//
$db->apply('Person', ['id' => $db::PRIMARY_KEY, 'name' => '', 'surname' => "", 'age' => 0, 'address1' => 0, 'address2' => 0]);
//
$db->import('Person', [['name' => 'Frank', 'surname' => 'Joy', 'address1' => 1, 'address2' => 3, 'sex' => 'M'], ['name' => 'Dana', 'surname' => 'Ci', 'address1' => 2, 'address2' => 4, 'sex' => 'F']]);
die;
//
$db->drop('Address', 'confirm');
//
$db->apply('Address', ['id' => $db::PRIMARY_KEY, 'name' => '', 'lat' => 0.0, 'lng' => 0.0, 'city' => '']);
//
$db->import('Address', [['name' => 'Route Red', 'lat' => 10.1, 'lng' => 1.2, 'city' => 'Palermo'], ['name' => 'Grenn Place', 'lat' => 31.4, 'lng' => 2.6, 'city' => 'Bruxel'], ['name' => 'Every Day', 'lat' => 52.3, 'lng' => 8.6, 'city' => 'Cann'], ['name' => 'New Moon', 'lat' => 71.2, 'lng' => 2.6, 'city' => 'Lione']]);
Exemple #8
0
 /**
  *
  *
  */
 public function setupDatabase()
 {
     //
     $db = Database::getDefault();
     //
     if (!$db->isReady()) {
         //
         echo '<h1>Setup database</h1>';
         //
         $this->drawRefresh();
     }
 }
<?php

//
echo '<h1>Test if table exists</h1>';
//
require_once '../common.php';
// require library
require_once '../../src/Javanile/SchemaDB/autoload.php';
//
use Javanile\SchemaDB;
//
$db = new SchemaDB\Database(array('host' => $host, 'user' => $user, 'pass' => $pass, 'name' => $name, 'pref' => 't100_'));
// drop tables
#$db->drop('confirm');
// create table
#$db->applyTable('Project', array('id' => 0));
//
if ($db->tableExists('Project')) {
    echo 'Table already exists!';
} else {
    echo 'No table found.';
}