mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
#18674718 : remove redundant domain name for adding unique index
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7274 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
1899ac4712
commit
a39de44640
3 changed files with 61 additions and 7 deletions
|
|
@ -290,17 +290,45 @@
|
|||
if(!$output->toBool()) return $output;
|
||||
}
|
||||
|
||||
|
||||
if($oDB->isIndexExists('sites','idx_domain')){
|
||||
$oDB->dropIndex('sites','idx_domain');
|
||||
}
|
||||
if(!$oDB->isIndexExists('sites','unique_domain')){
|
||||
$oDB->addIndex('sites','unique_domain',array('domain'),true);
|
||||
}
|
||||
if($oDB->isIndexExists('sites','idx_domain')){
|
||||
$oDB->dropIndex('sites','idx_domain');
|
||||
}
|
||||
if(!$oDB->isIndexExists('sites','unique_domain')){
|
||||
$this->updateForUniqueSiteDomain();
|
||||
$oDB->addIndex('sites','unique_domain',array('domain'),true);
|
||||
}
|
||||
|
||||
return new Object(0, 'success_updated');
|
||||
}
|
||||
|
||||
function updateForUniqueSiteDomain()
|
||||
{
|
||||
$output = executeQueryArray("module.getNonuniqueDomains");
|
||||
if(!$output->data) return;
|
||||
foreach($output->data as $data)
|
||||
{
|
||||
if($data->count == 1) continue;
|
||||
$domain = $data->domain;
|
||||
$args = null;
|
||||
$args->domain = $domain;
|
||||
$output2 = executeQueryArray("module.getSiteByDomain", $args);
|
||||
$bFirst = true;
|
||||
foreach($output2->data as $site)
|
||||
{
|
||||
if($bFirst)
|
||||
{
|
||||
$bFirst = false;
|
||||
continue;
|
||||
}
|
||||
$domain .= "_";
|
||||
$args = null;
|
||||
$args->domain = $domain;
|
||||
$args->site_srl = $site->site_srl;
|
||||
$output3 = executeQuery("module.updateSite", $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 캐시 파일 재생성
|
||||
**/
|
||||
|
|
|
|||
12
modules/module/queries/getNonuniqueDomains.xml
Normal file
12
modules/module/queries/getNonuniqueDomains.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<query id="getNonuniqueDomains" action="select">
|
||||
<tables>
|
||||
<table name="sites" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="domain" />
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<groups>
|
||||
<group column="domain" />
|
||||
</groups>
|
||||
</query>
|
||||
14
modules/module/queries/getSiteByDomain.xml
Normal file
14
modules/module/queries/getSiteByDomain.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<query id="getSiteInfoByDomain" action="select">
|
||||
<tables>
|
||||
<table name="sites" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="sites.domain" var="domain" notnull="notnull" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="site_srl" order="desc" />
|
||||
</navigation>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue