mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
sort dbms as priority
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12129 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
fc891a8fe1
commit
7a7ee712b6
1 changed files with 47 additions and 1 deletions
|
|
@ -45,6 +45,18 @@
|
|||
*/
|
||||
class DB {
|
||||
|
||||
/**
|
||||
* priority of DBMS
|
||||
* @var array
|
||||
*/
|
||||
var $priority_dbms = array(
|
||||
'mysqli' => 5,
|
||||
'mysql' => 4,
|
||||
'mysql_innodb' => 3,
|
||||
'cubrid' => 2,
|
||||
'mssql' => 1
|
||||
);
|
||||
|
||||
/**
|
||||
* count cache path
|
||||
* @var string
|
||||
|
|
@ -250,7 +262,6 @@
|
|||
$db_classes_path = _XE_PATH_."classes/db/";
|
||||
$filter = "/^DB([^\.]+)\.class\.php/i";
|
||||
$supported_list = FileHandler::readDir($db_classes_path, $filter, true);
|
||||
sort($supported_list);
|
||||
|
||||
// after creating instance of class, check is supported
|
||||
for($i = 0; $i < count($supported_list); $i++) {
|
||||
|
|
@ -275,10 +286,45 @@
|
|||
|
||||
$get_supported_list[] = $obj;
|
||||
}
|
||||
|
||||
// sort
|
||||
@usort($get_supported_list, array($this, '_sortDBMS'));
|
||||
|
||||
$this->supported_list = $get_supported_list;
|
||||
return $this->supported_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort dbms as priority
|
||||
*/
|
||||
function _sortDBMS($a, $b)
|
||||
{
|
||||
if(!isset($this->priority_dbms[$a->db_type]))
|
||||
{
|
||||
$priority_a = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$priority_a = $this->priority_dbms[$a->db_type];
|
||||
}
|
||||
|
||||
if(!isset($this->priority_dbms[$b->db_type]))
|
||||
{
|
||||
$priority_b = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$priority_b = $this->priority_dbms[$b->db_type];
|
||||
}
|
||||
|
||||
if($priority_a == $priority_b)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($priority_a > $priority_b) ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dbms supportable status
|
||||
* The value is set in the child class
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue