本文整理汇总了PHP中CM_Db_Db::describeColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Db_Db::describeColumn方法的具体用法?PHP CM_Db_Db::describeColumn怎么用?PHP CM_Db_Db::describeColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CM_Db_Db
的用法示例。
在下文中一共展示了CM_Db_Db::describeColumn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDescribeColumnThrowsException
public function testDescribeColumnThrowsException()
{
CM_Db_Db::exec('
CREATE TABLE `test2` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
)');
try {
CM_Db_Db::describeColumn('test2', 'id');
CM_Db_Db::describeColumn('test2', 'id1');
$this->fail('Column doesn\'t exist');
} catch (CM_Db_Exception $e) {
$this->assertContains('`id1`', $e->getMessage());
}
try {
CM_Db_Db::describeColumn('test_', 'id');
$this->fail('Table doesn\'t exist');
} catch (CM_Db_Exception $e) {
$this->assertContains('`id`', $e->getMessage());
}
CM_Db_Db::exec('DROP TABLE `test2`');
}
示例2: testDescribeColumnThrowsException
public function testDescribeColumnThrowsException()
{
CM_Db_Db::exec('
CREATE TABLE `test2` (
`id` INT(12) UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
)');
try {
CM_Db_Db::describeColumn('test2', 'id');
CM_Db_Db::describeColumn('test2', 'id1');
$this->fail('Column doesn\'t exist');
} catch (CM_Db_Exception $e) {
$this->assertSame('Column not found', $e->getMessage());
$this->assertSame(['column' => 'id1'], $e->getMetaInfo());
}
try {
CM_Db_Db::describeColumn('test_', 'id');
$this->fail('Table doesn\'t exist');
} catch (CM_Db_Exception $e) {
$this->assertContains('`id`', $e->getMetaInfo()['query']);
}
CM_Db_Db::exec('DROP TABLE `test2`');
}
示例3: decimal
<?php
if ('1.00' === CM_Db_Db::describeColumn('cm_splittestVariation_fixture', 'conversionWeight')->getDefaultValue()) {
CM_Db_Db::exec('ALTER TABLE cm_splittestVariation_fixture
MODIFY COLUMN conversionWeight decimal(10,2) NOT NULL DEFAULT 0');
CM_Db_Db::update('cm_splittestVariation_fixture', array('conversionWeight' => 0), array('conversionStamp' => null));
}
示例4: int
<?php
// To be run in prod beforehand:
// pt-online-schema-change --execute --charset=utf8 --user=root --ask-pass --database=skadate t=cm_user --alter='CHANGE `site` `site` int(10) unsigned DEFAULT NULL'
if ('INT' !== CM_Db_Db::describeColumn('cm_user', 'site')->getType()) {
CM_Db_Db::exec("ALTER TABLE `cm_user` CHANGE `site` `site` int(10) unsigned DEFAULT NULL;");
}
示例5: INT
<?php
if (!CM_Db_Db::describeColumn('cm_stream_subscribe', 'allowedUntil')->getAllowNull()) {
CM_Db_Db::exec("ALTER TABLE cm_stream_subscribe CHANGE allowedUntil allowedUntil INT(10) UNSIGNED DEFAULT NULL");
}
if (!CM_Db_Db::describeColumn('cm_stream_publish', 'allowedUntil')->getAllowNull()) {
CM_Db_Db::exec("ALTER TABLE cm_stream_publish CHANGE allowedUntil allowedUntil INT(10) UNSIGNED DEFAULT NULL");
}
示例6: int
<?php
if (CM_Db_Db::describeColumn('cm_stream_publish', 'allowedUntil')->getAllowNull()) {
CM_Db_Db::exec('ALTER TABLE `cm_stream_publish` CHANGE `allowedUntil` `allowedUntil` int(10) unsigned NOT NULL');
}
if (CM_Db_Db::describeColumn('cm_stream_subscribe', 'allowedUntil')->getAllowNull()) {
CM_Db_Db::exec('ALTER TABLE `cm_stream_subscribe` CHANGE `allowedUntil` `allowedUntil` int(10) unsigned NOT NULL');
}
示例7: INT
<?php
if (!CM_Db_Db::describeColumn('cm_streamChannelArchive_video', 'userId')->getAllowNull()) {
CM_Db_Db::exec('ALTER TABLE `cm_streamChannelArchive_video` CHANGE `userId` `userId` INT( 10 ) UNSIGNED NULL ;');
}