コード例 #1
0
    protected function setUp()
    {
        parent::setUp();
        $dbw = wfGetDB(DB_MASTER);
        $isSqlite = $GLOBALS['wgDBtype'] === 'sqlite';
        $idField = $isSqlite ? 'INTEGER' : 'INT unsigned';
        $primaryKey = $isSqlite ? 'PRIMARY KEY AUTOINCREMENT' : 'auto_increment PRIMARY KEY';
        $dbw->query('CREATE TABLE IF NOT EXISTS ' . $dbw->tableName('orm_test') . '(
				test_id                    ' . $idField . '        NOT NULL ' . $primaryKey . ',
				test_name                  VARCHAR(255)        NOT NULL,
				test_age                   TINYINT unsigned    NOT NULL,
				test_height                FLOAT               NOT NULL,
				test_awesome               TINYINT unsigned    NOT NULL,
				test_stuff                 BLOB                NOT NULL,
				test_moarstuff             BLOB                NOT NULL,
				test_time                  varbinary(14)       NOT NULL
			);');
    }
コード例 #2
0
    protected function setUp()
    {
        parent::setUp();
        $dbw = wfGetDB(DB_MASTER);
        $isSqlite = $GLOBALS['wgDBtype'] === 'sqlite';
        $isPostgres = $GLOBALS['wgDBtype'] === 'postgres';
        $idField = $isSqlite ? 'INTEGER' : 'INT unsigned';
        $primaryKey = $isSqlite ? 'PRIMARY KEY AUTOINCREMENT' : 'auto_increment PRIMARY KEY';
        if ($isPostgres) {
            $dbw->query('CREATE TABLE IF NOT EXISTS ' . $dbw->tableName('orm_test') . "(\n\t\t\t\t\ttest_id serial PRIMARY KEY,\n\t\t\t\t\ttest_name TEXT NOT NULL DEFAULT '',\n\t\t\t\t\ttest_age INTEGER NOT NULL DEFAULT 0,\n\t\t\t\t\ttest_height REAL NOT NULL DEFAULT 0,\n\t\t\t\t\ttest_awesome INTEGER NOT NULL DEFAULT 0,\n\t\t\t\t\ttest_stuff BYTEA,\n\t\t\t\t\ttest_moarstuff BYTEA,\n\t\t\t\t\ttest_time TIMESTAMPTZ\n\t\t\t\t\t);", __METHOD__);
        } else {
            $dbw->query('CREATE TABLE IF NOT EXISTS ' . $dbw->tableName('orm_test') . '(
					test_id                    ' . $idField . '        NOT NULL ' . $primaryKey . ',
					test_name                  VARCHAR(255)        NOT NULL,
					test_age                   TINYINT unsigned    NOT NULL,
					test_height                FLOAT               NOT NULL,
					test_awesome               TINYINT unsigned    NOT NULL,
					test_stuff                 BLOB                NOT NULL,
					test_moarstuff             BLOB                NOT NULL,
					test_time                  varbinary(14)       NOT NULL
				);', __METHOD__);
        }
    }