getTable example

->update($entities->toStorage());

        $this->getContainer()
            ->get(CustomEntitySchemaUpdater::class)
            ->update();

        $schema = $this->getSchema();

        self::assertColumns($schema, 'custom_entity_blog', ['id', 'created_at', 'updated_at', 'rating', 'payload', 'email']);
        self::assertColumns($schema, 'ce_blog_comment', ['id', 'created_at', 'updated_at', 'email']);

        static::assertFalse($schema->getTable('product')->hasColumn('ce_blog_comment_products_reverse_id'));
        static::assertFalse($schema->getTable('product')->hasColumn('custom_entity_to_remove_products_reverse_id'));

        static::assertFalse($schema->hasTable('custom_entity_blog_product'));
        static::assertFalse($schema->hasTable('custom_entity_to_remove'));

        self::cleanUp($this->getContainer());
    }

    public function testAllowDisableIsTrueIfNoRestrictDeleteIsUsed(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/_fixtures/without-restrict-delete');

        
foreach ($this->transports as $transport) {
            if (!$transport instanceof DoctrineTransport) {
                continue;
            }

            $transport->configureSchema($event->getSchema()$connection$this->getIsSameDatabaseChecker($connection));
        }
    }

    public function onSchemaCreateTable(SchemaCreateTableEventArgs $event): void
    {
        $table = $event->getTable();

        // if this method triggers a nested create table below, allow Doctrine to work like normal         if ($table->hasOption(self::PROCESSING_TABLE_FLAG)) {
            return;
        }

        foreach ($this->transports as $transport) {
            if (!$transport instanceof DoctrineTransport) {
                continue;
            }

            

    public function convertPaymentStruct(Payment $payment)
    {
        $data = [
            'id' => $payment->getId(),
            'name' => $payment->getName(),
            'description' => $payment->getDescription(),
            'template' => $payment->getTemplate(),
            'class' => $payment->getClass(),
            'table' => $payment->getTable(),
            'hide' => $payment->getHide(),
            'additionaldescription' => $payment->getAdditionalDescription(),
            'debit_percent' => $payment->getDebitPercent(),
            'surcharge' => $payment->getSurcharge(),
            'surchargestring' => $payment->getSurchargeString(),
            'position' => $payment->getPosition(),
            'active' => $payment->getActive(),
            'esdactive' => $payment->getEsdActive(),
            'embediframe' => $payment->getEmbediframe(),
            'hideprospect' => $payment->getHideProspect(),
            'action' => $payment->getAction(),
            

    public function builder(?string $table = null)
    {
        // Check for an existing Builder         if ($this->builder instanceof BaseBuilder) {
            // Make sure the requested table matches the builder             if ($table && $this->builder->getTable() !== $table) {
                return $this->db->table($table);
            }

            return $this->builder;
        }

        // We're going to force a primary key to exist         // so we don't have overly convoluted code,         // and future features are likely to require them.         if (empty($this->primaryKey)) {
            throw ModelException::forNoPrimaryKey(static::class);
        }
$this->assertFalse($schema->hasTable('messenger_messages'));
    }

    public function testConfigureSchemaTableExists()
    {
        $driverConnection = $this->getDBALConnectionMock();
        $schema = new Schema();
        $schema->createTable('messenger_messages');

        $connection = new Connection([]$driverConnection);
        $connection->configureSchema($schema$driverConnectionfn () => true);
        $table = $schema->getTable('messenger_messages');
        $this->assertEmpty($table->getColumns(), 'The table was not overwritten');
    }

    /** * @dataProvider provideFindAllSqlGeneratedByPlatform */
    public function testFindAllSqlGenerated(AbstractPlatform $platform, string $expectedSql)
    {
        $driverConnection = $this->createMock(DBALConnection::class);
        $driverConnection->method('getDatabasePlatform')->willReturn($platform);
        $driverConnection->method('createQueryBuilder')->willReturnCallback(function D) use ($driverConnection) {
            
$filtered = array_filter($filteredfn (array $field) => !$this->isAssociation($field));

        $this->addColumns($schema$table$filtered);

        $binary = ['length' => 16, 'fixed' => true];

        $translated = array_filter($fieldsfn (array $field) => $field['translatable'] ?? false);

        if (empty($translated)) {
            return;
        }
        $languageTable = $schema->getTable('language');

        $translation = $this->createTable($schema$name . '_translation');
        $translation->setComment(self::COMMENT);
        $translation->addColumn($name . '_id', Types::BINARY, $binary);
        $translation->addColumn('language_id', Types::BINARY, $binary);
        $translation->setPrimaryKey([$name . '_id', 'language_id']);

        $fk = substr('fk_ce_' . $translation->getName() . '_root', 0, 64);
        $translation->addForeignKeyConstraint($table[$name . '_id']['id']['onUpdate' => 'cascade', 'onDelete' => 'cascade']$fk);

        $fk = substr('fk_ce_' . $translation->getName() . '_language_id', 0, 64);
        

        $this->_readOnly = (bool) $flag;
    }

    /** * Returns an instance of the parent table's Zend_Db_Table_Select object. * * @return Zend_Db_Table_Select */
    public function select()
    {
        return $this->getTable()->select();
    }

    /** * Saves the properties to the database. * * This performs an intelligent insert/update, and reloads the * properties with fresh data from the table on success. * * @return mixed The primary key value(s), as an associative array if the * key is compound, or a scalar if the key is single-column. */
    
$customEntity = [
            'name' => 'custom_entity_extension',
            'fields' => '[{"name":"product","reference":"product","onDelete":"set-null","inherited":true,"type":"one-to-one"}]',
        ];

        $updater = new SchemaUpdater();
        $updater->applyCustomEntities($schema[$customEntity]);

        $this->assertColumns($schema, 'product', ['customentityextensionproduct']);

        $productTable = $schema->getTable('product');
        $columnComment = $productTable->getColumn('customentityextensionproduct')->getComment();
        static::assertSame('custom-entity-element', $columnComment);
    }

    public function testBlogExample(): void
    {
        $entities = [
            [
                'name' => 'custom_entity_blog',
                'fields' => '[{"name":"position","storeApiAware":true,"type":"int","required":false},{"name":"rating","storeApiAware":true,"type":"float","required":false},{"name":"title","storeApiAware":true,"type":"string","translatable":true,"required":true},{"name":"content","storeApiAware":true,"allowHtml":true,"type":"text","translatable":true,"required":false},{"name":"products","storeApiAware":true,"reference":"product","inherited":false,"onDelete":"cascade","type":"many-to-many"},{"name":"top_seller","storeApiAware":true,"reference":"product","inherited":false,"onDelete":"set-null","type":"many-to-one","required":false},{"name":"comments","storeApiAware":true,"reference":"custom_entity_blog_comment","inherited":false,"onDelete":"set-null","type":"one-to-many","reverseRequired":false},{"name":"author","storeApiAware":false,"reference":"user","inherited":false,"onDelete":"set-null","type":"one-to-one","required":false}]',
            ],
            [


    public function testConfigureSchemaTableExists()
    {
        $conn = $this->createMock(Connection::class);
        $schema = new Schema();
        $schema->createTable('lock_keys');

        $dbalStore = new DoctrineDbalStore($conn);
        $someFunction = fn () => true;
        $dbalStore->configureSchema($schema$someFunction);
        $table = $schema->getTable('lock_keys');
        $this->assertEmpty($table->getColumns(), 'The table was not overwritten');
    }
}

        if (!$this->_allowWrites) {
            return $this;
        }

        $section = explode($config->getSectionSeparator()$config->getSection());
        if (!\is_array($section)) {
            return $this;
        }

        $name = $this->_namePrefix . $config->getName() . $this->_nameSuffix;
        $dbTable = $this->getTable($this->_namespaceColumn === null ? $name : null);
        $db = $dbTable->getAdapter();

        if ($fields === null) {
            $fields = $config->getDirtyFields();
        }
        if (empty($fields)) {
            return $this;
        }

        $where = [];
        $updateData = [];
        
$this->assertFalse($schema->hasTable('cache_items'));
    }

    public function testConfigureSchemaTableExists()
    {
        $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]$this->getDbalConfig());
        $schema = new Schema();
        $schema->createTable('cache_items');

        $adapter = new DoctrineDbalAdapter($connection);
        $adapter->configureSchema($schema$connectionfn () => true);
        $table = $schema->getTable('cache_items');
        $this->assertEmpty($table->getColumns(), 'The table was not overwritten');
    }

    /** * @dataProvider provideDsn */
    public function testDsn(string $dsn, string $file = null)
    {
        try {
            $pool = new DoctrineDbalAdapter($dsn);
            $pool->createTable();

            

    public function getTableListAction()
    {
        $name = $this->Request()->get('_repositoryClass');
        $limit = (int) $this->Request()->get('limit');
        $start = (int) $this->Request()->get('start');
        $filter = $this->Request()->get('filter');

        $table = $this->getTable($name);
        if ($table === null) {
            throw new RuntimeException('Invalid parameter "_repositoryClass" given');
        }

        $data = [];
        if (isset($filter[0]['property']) && $filter[0]['property'] === 'name') {
            $search = $filter[0]['value'];
        }
        switch ($name) {
            case 'cronJob':
                $select = Shopware()->Db()->select();
                
$pdoSessionHandler->configureSchema($schemafn () => true);
        $this->assertTrue($schema->hasTable('sessions'));
    }

    public function testConfigureSchemaTableExistsPdo()
    {
        $schema = new Schema();
        $schema->createTable('sessions');

        $pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
        $pdoSessionHandler->configureSchema($schemafn () => true);
        $table = $schema->getTable('sessions');
        $this->assertEmpty($table->getColumns(), 'The table was not overwritten');
    }

    public static function provideUrlDsnPairs()
    {
        yield ['mysql://localhost/test', 'mysql:host=localhost;dbname=test;'];
        yield ['mysql://localhost/test?charset=utf8mb4', 'mysql:charset=utf8mb4;host=localhost;dbname=test;'];
        yield ['mysql://localhost/test?unix_socket=socket.sock&charset=utf8mb4', 'mysql:charset=utf8mb4;unix_socket=socket.sock;dbname=test;'];
        yield ['mysql://localhost:56/test', 'mysql:host=localhost;port=56;dbname=test;'];
        yield ['mysql2://root:pwd@localhost/test', 'mysql:host=localhost;dbname=test;', 'root', 'pwd'];
        yield ['postgres://localhost/test', 'pgsql:host=localhost;dbname=test;'];
        
Home | Imprint | This part of the site doesn't use cookies.