【问题标题】:PHP Zend Doctrine\DBAL\Types\Type bitPHP Zend Doctrine\DBAL\Types\Type 位
【发布时间】:2018-09-26 20:28:40
【问题描述】:

我将 Doctrine DBAL 与 Zend Famework 3 一起使用,我想使用 BIT(64) 字段。 我可以看到以下支持类型: https://www.doctrine-project.org/api/dbal/2.7/Doctrine/DBAL/Types/Type.html 是否可以用BIT字段类型扩展它:https://dev.mysql.com/doc/refman/8.0/en/bit-type.html

我需要使用权限掩码之类的东西。

下面是简单的代码:

namespace Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

class Version1 extends AbstractMigration {
    /**
     * Upgrades the schema to its newer state.
     * @param Schema $schema
     */
    public function up(Schema $schema) {
        $table = $schema->createTable('user');
        $table->addColumn('id', 'integer', ['autoincrement' => true, 'unsigned' => true]);
        $table->addColumn('bitmask', 'bit??', []);
        $table->setPrimaryKey(['id']);
        $table->addOption('engine', 'InnoDB');
    }
}

【问题讨论】:

    标签: php doctrine-orm zend-framework3


    【解决方案1】:

    我已经创建了普通的 BIGINT(20) UNSIGNED 字段,在 php 中使用它作为 BIT 值,一切正常。

    【讨论】:

      猜你喜欢
      • 2016-04-16
      • 2014-07-21
      • 2019-08-27
      • 2022-08-08
      • 1970-01-01
      • 2011-07-15
      • 2017-07-20
      • 2011-10-07
      • 2014-04-30
      相关资源
      最近更新 更多