コード例 #1
0
 /**
  * get the foreign key object from a db result array
  *
  * @param   string[] dbresult array
  * @return  rdbms.DBForeignKeyConstraint
  */
 private function parseForeignKey($db_constraint)
 {
     $cstring = $db_constraint['definition'];
     $bracestrings = $this->subBracerString($cstring);
     $strings = explode(' ', $cstring);
     $attributes = [];
     foreach ($bracestrings as $bracestring) {
         $attributes[] = $this->extractParams($bracestring);
     }
     $constraint = new \rdbms\DBForeignKeyConstraint();
     $constraint->setSource($strings[5]);
     $constraint->setName($db_constraint['name']);
     $constraint->setKeys(array_combine($attributes[0], $attributes[1]));
     return $constraint;
 }
コード例 #2
0
 /**
  * get the foreign key object from a string
  *
  * @param   string parsestring
  * @return  rdbms.DBForeignKeyConstraint
  */
 private function parseForeignKeyString($string)
 {
     $constraint = new \rdbms\DBForeignKeyConstraint();
     $quotstrings = [];
     $bracestrings = [];
     $attributes = [];
     $pos = 10;
     while (++$pos < strlen($string)) {
         switch ($string[$pos]) {
             case '`':
                 $quotstrings[] = $this->parseQuoteString($string, $pos, '`');
                 break;
             case '"':
                 $quotstrings[] = $this->parseQuoteString($string, $pos, '"');
                 break;
             case '(':
                 $bracestrings[] = $this->parseBracerString($string, $pos);
                 break;
         }
     }
     foreach ($bracestrings as $bracestring) {
         $params = $this->extractParams($bracestring);
         foreach ($params as $i => $param) {
             $params[$i] = substr($param, 1, -1);
         }
         $attributes[] = $params;
     }
     $constraint->setKeys(array_combine($attributes[0], $attributes[1]));
     $constraint->setName($quotstrings[0]);
     $constraint->setSource($quotstrings[1]);
     return $constraint;
 }