예제 #1
0
파일: Foreign.php 프로젝트: nmx/Modyllic
 function equal_to(Modyllic_Schema_Index $other, array $fromnames = null)
 {
     if (!parent::equal_to($other)) {
         return false;
     }
     if ($this->references != $other->references) {
         return false;
     }
     if ($this->weak != $other->weak) {
         return false;
     }
     return true;
 }
예제 #2
0
파일: Table.php 프로젝트: nmx/Modyllic
 /**
  * @param Modyllic_Schema_Index $index
  */
 function add_index(Modyllic_Schema_Index $index)
 {
     $name = $index->get_name();
     if (isset($this->indexes[$name])) {
         throw new Exception("In table " . $this->name . "- duplicate key name " . $name);
     }
     $this->indexes[$name] = $index;
     $this->last_index = $index;
     foreach ($index->columns as $cname => $value) {
         if (!isset($this->columns[$cname])) {
             throw new Exception("In table " . $this->name . ", index {$name}, can't index unknown column {$cname}");
         }
     }
     // If this is a primary key and has only one column then we'll flag that column as a primary key
     if ($index->primary and count($index->columns) == 1) {
         $name = current(array_keys($index->columns));
         $len = current(array_values($index->columns));
         // And if there's no length limiter on the column...
         if ($len === false) {
             $this->columns[$name]->is_primary = true;
         }
     }
     return $index;
 }
예제 #3
0
파일: Parser.php 프로젝트: nmx/Modyllic
 function add_index(Modyllic_Schema_Index $key)
 {
     // If a semantically identical key already exists, replace it.
     $match = null;
     foreach ($this->ctx->indexes as $array_index => &$index) {
         if ($key->equal_to($index)) {
             $match = $array_index;
             break;
         }
     }
     if (isset($match)) {
         unset($this->ctx->indexes[$match]);
     }
     $this->ctx->add_index($key);
 }