Ejemplo n.º 1
0
 public static function export(\PDO $database, $databaseName)
 {
     try {
         $stmt = $database->query('SHOW TABLES');
         $db = new Database($databaseName);
         foreach ($stmt as $k => $v) {
             $table = new Table();
             $table->setName($v[0]);
             $query = $database->query('SHOW COLUMNS FROM ' . $table->getName());
             $columns = $query->fetchAll(\PDO::FETCH_ASSOC);
             foreach ($columns as $c) {
                 $column = new Column();
                 $column->setName($c['Field']);
                 $column->setDefault($c['Default']);
                 $column->setExtra($c['Extra']);
                 $column->setKey($c['Key']);
                 $column->setNull($c['Null']);
                 $column->setType($c['Type']);
                 $table->addColumn($column);
             }
             $db->addTable($table);
         }
         $stmt->closeCursor();
     } catch (\PDOException $e) {
         echo "Error: " . $e->getMessage();
         exit;
     }
     return $db;
 }
Ejemplo n.º 2
0
 function it_can_add_many_tables(Table $table1, Table $table2, Table $table3)
 {
     $table1->getName()->willReturn('users');
     $table2->getName()->willReturn('products');
     $table3->getName()->willReturn('categories');
     $this->addTable($table1);
     $this->addTable($table2);
     $this->addTable($table3);
     $this->getTables()->shouldHaveCount(3);
 }
Ejemplo n.º 3
0
 function it_return_query(Column $column, Table $table)
 {
     $table->getName()->willReturn('dbdiff');
     $column->getQueryString()->willReturn('id int(10) unsigned NOT NULL PRIMARY KEY auto_increment');
     $this::query($column, $table)->shouldBe('ALTER TABLE dbdiff MODIFY id int(10) unsigned NOT NULL PRIMARY KEY auto_increment');
 }