コード例 #1
0
 /**
  * @return ColumnFragment[]
  */
 public function getColumnList()
 {
     $columnList = [];
     foreach ($this->schema->getPropertyList() as $property) {
         $columnList[$property->getName()] = new ColumnFragment($property);
     }
     return array_merge($this->columnList, $columnList);
 }
コード例 #2
0
ファイル: SqliteStorage.php プロジェクト: edde-framework/edde
 /**
  * truncate given schema (clear all data, even if it has relations)
  *
  * @param ISchema $schema
  */
 public function truncate(ISchema $schema)
 {
     $this->connected();
     $result = $this->pdo->prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?;");
     $result->execute([$schema->getName()]);
     if ($result->fetch() !== false) {
         $this->pdo->exec('DELETE FROM ' . $this->delimite($schema->getName()));
     }
 }
コード例 #3
0
ファイル: ScannerFile.php プロジェクト: edde-framework/edde
 /**
  * @return ISchema
  */
 public function schema()
 {
     if ($this->schema === null) {
         $this->schema = new Schema(static::class);
         $this->schema->addSchemaProperty(new SchemaProperty('file'));
         $this->schema->addSchemaProperty((new SchemaProperty('extension'))->setRequired(false));
         $this->schema->addSchemaProperty(new SchemaProperty('mime'));
         $this->schema->addSchemaProperty((new SchemaProperty('size'))->setType('int'));
         $this->schema->addSchemaProperty((new SchemaProperty('changed'))->setType('datetime'));
         $this->schema->addSchemaProperty((new SchemaProperty('stamp'))->setType('datetime'));
     }
     return $this->schema;
 }
コード例 #4
0
 /**
  * create the table from the given schema; this method needs to be optimized
  *
  * @param ISchema $schema
  *
  * @return $this
  */
 public function createSchema(ISchema $schema)
 {
     if ($this->cache->load($cacheId = 'schema.' . $schema->getName()) === true) {
         return $this;
     }
     $createTableQuery = new CreateTableQuery($schema);
     $createTableQuery->setIfNotExists();
     $createTableQuery->addColumn(new ColumnFragment($this->createPrimaryProperty()));
     $this->exec($createTableQuery);
     $this->cache->save($cacheId, true);
     return $this;
 }