Пример #1
0
 /**
  * The element handler functions for the XML parser
  *
  *  @link http://www.php.net/manual/en/function.xml-set-element-handler.php
  */
 protected function xmlEndTag($parser, $name)
 {
     switch ($name) {
         case 'column':
         case 'table':
         case 'schema':
         case 'datatype':
         case 'alternate':
         case 'pick':
         case 'random':
         case 'when':
         case 'swap':
         case 'foreign-key':
             $this->builder->end();
             break;
     }
 }
Пример #2
0
 /**
  *  Using the db connection will build the
  *  type composite ready to convert to xml
  *
  *  @param Doctrine\DBAL\Connection
  *  @param Faker\Components\Engine\XML\Builder\NodeBuilder $builder
  */
 public function analyse(Connection $db, NodeBuilder $builder)
 {
     $sm = $db->getSchemaManager();
     # add schema element
     $builder->addSchema($db->getDatabase(), array());
     # add writer for the platform
     $builder->addWriter($db->getDatabasePlatform()->getName(), 'sql');
     # iterate over the table
     $tables = $sm->listTables();
     foreach ($tables as $table) {
         $builder->addTable($table->getName(), array('generate' => 0));
         foreach ($table->getColumns() as $column) {
             $builder->addColumn($column->getName(), array('type' => $column->getType()->getName()))->addType('alphanumeric', array())->setTypeOption('format', 'ccccc')->end()->end();
         }
         $builder->end();
     }
     $builder->end();
     return $builder->build();
 }