コード例 #1
0
ファイル: mysql-2.0.1.php プロジェクト: nicolargo/frontend
$sql = <<<SQL
    ALTER TABLE `{$this->mySqlTablePrefix}{$table}` DROP PRIMARY KEY
    ALTER TABLE `{$this->mySqlTablePrefix}{$table}` UPDATE `id` VARCHAR(127)
    ALTER TABLE `{$this->mySqlTablePrefix}{$table}` PRIMARY KEY (`id`)
SQL;
$status = $status && mysql_2_0_1($sql);
/* webhook */
$table = 'webhook';
$sql = <<<SQL
    ALTER TABLE `{$this->mySqlTablePrefix}{$table}` DROP KEY `id`
    ALTER TABLE `{$this->mySqlTablePrefix}{$table}` UPDATE `id` VARCHAR(127)
    ALTER TABLE `{$this->mySqlTablePrefix}{$table}` UPDATE `owner` VARCHAR(127)
    ALTER TABLE `{$this->mySqlTablePrefix}{$table}` UNIQUE KEY `id` (`id`,`owner`)
SQL;
$status = $status && mysql_2_0_1($sql);
$sql = <<<SQL
  UPDATE `{$this->mySqlTablePrefix}admin` SET `value`=:version WHERE `key`=:key
SQL;
$status = $status && mysql_2_0_1($sql, array(':key' => 'version', ':version' => '2.0.1'));
function mysql_2_0_1($sql, $params = array())
{
    try {
        getDatabase()->execute($sql, $params);
        getLogger()->info($sql);
    } catch (Exception $e) {
        getLogger()->crit($e->getMessage());
        return false;
    }
    return true;
}
return $status;
コード例 #2
0
ファイル: mysql-2.0.1.php プロジェクト: gg1977/frontend
  ALTER TABLE `{$this->mySqlTablePrefix}photo` ADD INDEX ( `owner` ) ;
SQL;
$status = $status && mysql_2_0_1($sql);
// dateSortByDay
$sql = <<<SQL
  ALTER TABLE `{$this->mySqlTablePrefix}photo` ADD `dateSortByDay` VARCHAR( 14 ) NOT NULL AFTER `dateUploadedYear`;
SQL;
$status = $status && mysql_2_0_1($sql);
$sql = <<<SQL
  UPDATE `{$this->mySqlTablePrefix}photo` SET dateSortByDay= CONCAT(
    CAST(dateTakenYear AS CHAR),
    LPAD(CAST(dateTakenMonth AS CHAR),2,"0"),
    LPAD(CAST(dateTakenDay AS CHAR),2,"0"),
    LPAD(23-HOUR(FROM_UNIXTIME(dateTaken)),2,"0"),
    LPAD(59-MINUTE(FROM_UNIXTIME(dateTaken)),2,"0"),
    LPAD(59-SECOND(FROM_UNIXTIME(dateTaken)),2,"0")
  );
SQL;
$status = $status && mysql_2_0_1($sql);
function mysql_2_0_1($sql, $params = array())
{
    try {
        getDatabase()->execute($sql, $params);
        getLogger()->info($sql);
    } catch (Exception $e) {
        getLogger()->crit($e->getMessage());
        return false;
    }
    return true;
}
return $status;