25 public static function mergeTables($toTable, $fromTable, $fldMap, $fldCondition)
27 $dbConnection = Main\HttpApplication::getConnection();
28 $dbHelper = $dbConnection->getSqlHelper();
30 $toTable = $dbHelper->forSql(trim($toTable));
31 $fromTable = $dbHelper->forSql(trim($fromTable));
33 if(!mb_strlen($toTable) || !mb_strlen($fromTable) || !is_array($fldMap) || empty($fldMap) || empty($fldCondition))
38 $sql =
'update '.$toTable.
', '.$fromTable.
' set ';
41 foreach($fldMap as $toFld => $fromFld)
42 $fields[] = $toTable.
'.'.$dbHelper->forSql(trim($toFld)).
' = '.$fromTable.
'.'.$dbHelper->forSql(trim($fromFld));
44 $sql .= implode(
', ', $fields);
47 foreach($fldCondition as $left => $right)
48 $where[] = $toTable.
'.'.$dbHelper->forSql(trim($left)).
' = '.$fromTable.
'.'.$dbHelper->forSql(trim($right));
50 $sql .=
' where '.implode(
' and ', $where);
52 $dbConnection->query($sql);
89 $dbConnection = Main\HttpApplication::getConnection();
90 $dbHelper = $dbConnection->getSqlHelper();
92 $indexName = $dbHelper->forSql(trim($indexName));
93 $tableName = $dbHelper->forSql(trim($tableName));
95 if(!mb_strlen($indexName) || !mb_strlen($tableName))
98 if(!static::checkIndexNameExists($indexName, $tableName))
101 $dbConnection->query(
"alter table {$tableName} drop index {$indexName}");
120 $startIndex = intval($startIndex);
121 if($startIndex <= 0 || !mb_strlen($tableName))
124 $dbConnection = Main\HttpApplication::getConnection();
125 $dbHelper = $dbConnection->getSqlHelper();
127 $tableName = $dbHelper->forSql(trim($tableName));
129 $dbConnection->query(
'alter table '.$tableName.
' AUTO_INCREMENT = '.$startIndex);