コード例 #1
0
ファイル: IndexSchemaHelper.php プロジェクト: Yame-/mautic
 /**
  * @param $name
  *
  * @throws SchemaException
  */
 public function setName($name)
 {
     if (!$this->sm->tablesExist($this->prefix . $name)) {
         throw new SchemaException("Table {$name} does not exist!");
     }
     $this->table = $this->sm->listTableDetails($this->prefix . $name);
 }
コード例 #2
0
 /**
  * @param Config $config
  * @return EloquentModel
  * @throws GeneratorException
  */
 public function createModel(Config $config)
 {
     $model = new EloquentModel($config->get('class_name'), $config->get('base_class_name'), $config->get('table_name'));
     if (!$this->manager->tablesExist($this->tablePrefix . $model->getTableName())) {
         throw new GeneratorException(sprintf('Table %s does not exist', $this->tablePrefix . $model->getTableName()));
     }
     $this->setNamespace($model, $config)->setCustomProperties($model, $config)->setFields($model)->setRelations($model);
     return $model;
 }
コード例 #3
0
ファイル: FormLogListener.php プロジェクト: svobodni/web
 public function onSuccess(Form $form)
 {
     if (!Callback::create($this->checkConnection)->invoke() || !$this->schemaManager->tablesExist('users')) {
         return;
     }
     $presenter = $form->presenter;
     $logEntity = new LogEntity($this->user instanceof UserEntity ? $this->user : NULL, 'Venne\\Forms\\Form', NULL, LogEntity::ACTION_OTHER);
     $logEntity->setType($presenter->link('this'));
     $logEntity->setMessage('Configuration has been updated');
     $this->logRepository->save($logEntity);
 }
コード例 #4
0
 /**
  * constructor
  * @param string $table_name
  * @param Connection $conn
  */
 public function __construct($table_name, \Doctrine\DBAL\Connection $conn)
 {
     $this->conn = $conn;
     $this->table_name = $table_name;
     $this->quoted_table_name = $this->conn->quoteIdentifier($this->table_name);
     $this->sm = $this->conn->getSchemaManager();
     if (!$this->sm->tablesExist([$table_name])) {
         throw Schema\SchemaException::tableDoesNotExist($table_name);
     }
     foreach ($this->sm->listTableColumns($this->table_name) as $colum) {
         $this->columns[$colum->getName()] = $colum;
         $this->column_types[$colum->getName()] = $colum->getType()->getName();
     }
 }
コード例 #5
0
 private function tableExist()
 {
     try {
         $name = $this->em->getClassMetadata('RenderBundle:Queue')->getTableName();
         return $this->sm->tablesExist($name);
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #6
0
 /**
  * Determine if a table exists.
  *
  * @param string $table
  * @param bool   $throwException
  *
  * @return bool
  *
  * @throws SchemaException
  */
 public function checkTableExists($table, $throwException = false)
 {
     if ($this->sm->tablesExist($this->prefix . $table)) {
         if ($throwException) {
             throw new SchemaException($this->prefix . "{$table} already exists");
         }
         return true;
     }
     return false;
 }
コード例 #7
0
 /**
  * Determine if a table exists
  *
  * @param      $table
  * @param bool $throwException
  * @return bool
  */
 public function checkTableExists($table, $throwException = false)
 {
     if (!$this->sm->tablesExist($table)) {
         if ($throwException) {
             throw new SchemaUpdateException("{$table} does not exist");
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
コード例 #8
0
ファイル: Testdb.php プロジェクト: eddmash/powerorm
 /**
  * @param AbstractSchemaManager $schemaM
  * @param Schema                $schema
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**>
  */
 public function createTable($schemaM, $schema)
 {
     if ($schemaM->tablesExist('artists')) {
         $schemaM->dropTable('artists');
     }
     if ($schemaM->tablesExist('user')) {
         $schemaM->dropTable('user');
     }
     echo 'Tables :: ';
     $UTable = $schema->createTable('user');
     $UTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $UTable->addColumn('name', 'string', ['length' => 60]);
     $UTable->setPrimaryKey(['id']);
     $myTable = $schema->createTable('artists');
     $myTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $myTable->addColumn('user_id', 'integer', ['unsigned' => true]);
     $myTable->addColumn('name', 'string', ['length' => 60]);
     $myTable->setPrimaryKey(['id']);
     $myTable->addForeignKeyConstraint($UTable, array('user_id'), array('id'), array('onUpdate' => 'CASCADE'));
     $schemaM->createTable($UTable);
     $schemaM->createTable($myTable);
 }
コード例 #9
0
 /**
  * Returns true if all the given tables exist.
  *
  * @param  array $tables
  * @return bool
  */
 public function tablesExist($tables)
 {
     $tables = array_map([$this, 'replacePrefix'], (array) $tables);
     return $this->manager->tablesExist($tables);
 }
コード例 #10
0
 private function tableExists()
 {
     return $this->schemaManager->tablesExist(self::TABLE);
 }