예제 #1
0
 protected function initIndexes()
 {
     $query = "select * from information_schema.statistics " . "where table_name = '%s' and TABLE_SCHEMA = '%s' " . "order by INDEX_NAME, SEQ_IN_INDEX";
     $query = sprintf($query, $this->newtablename, $this->dbname);
     if (!($result = mysql_query($query, $this->conn))) {
         $this->raiseException('Failed to get index info ' . $query);
     }
     // save index info as array
     $this->indexes = array();
     // we are resetting the PK so that it will be used in later steps
     if ($this->flags & OSC_FLAGS_USE_NEW_PK) {
         $this->pkcolumnarray = array();
     }
     $prev_index_name = '';
     $index = null;
     $primary = null;
     while ($row = mysql_fetch_assoc($result)) {
         $index_name = quotify($row['INDEX_NAME']);
         $column_name = quotify($row['COLUMN_NAME']);
         if ($prev_index_name != $index_name) {
             // is the 1st column of the index autoincrement column?
             $auto = isset($this->autoIncrement) && $column_name === $this->autoIncrement;
             $index = new IndexInfo($this->newtablename, $index_name, $row['NON_UNIQUE'], $auto);
             if ($index->isPrimary()) {
                 $primary = $index;
             }
             $this->indexes[] = $index;
         }
         $index->addColumn($column_name, $row['SUB_PART']);
         if ($this->flags & OSC_FLAGS_USE_NEW_PK && $index->isPrimary()) {
             $this->pkcolumnarray[] = $column_name;
         }
         $prev_index_name = $index_name;
     }
     // re-create these strings with new array
     if ($this->flags & OSC_FLAGS_USE_NEW_PK) {
         $this->initColumnNameStrings();
     }
     $this->validatePostAlterPK($primary);
     $this->joinClauseReplay = $this->getJoinClauseReplay();
 }
예제 #2
0
/**
 * Convert list of string entities (e.g. UUID's)
 * into SQL list ('A', 'B', 'C')
 */
function convert_list($list)
{
    $list_image = "";
    foreach ($list as $elt) {
        if ($list_image != "") {
            $list_image = $list_image . ", ";
        }
        $list_image = $list_image . quotify($elt, 'text');
    }
    return "(" . $list_image . ")";
}