/** * Generates the expression for selecting rows with specified composite key values. * * @param TableSchema $table the table schema * @param array $values list of primary key values to be selected within * @param string $prefix column prefix (ended with dot) * * @return string the expression for selection * @throws \Exception */ protected function createCompositeInCondition($table, $values, $prefix) { $keyNames = array(); foreach (array_keys($values[0]) as $name) { /** @type ColumnSchema $column */ if (null === ($column = $table->getColumn($name))) { throw new \Exception("Table '{$table->name}' does not have a column named '{$name}'."); } $keyNames[] = $prefix . $column->rawName; } $vs = array(); foreach ($values as $value) { $vs[] = '(' . implode(', ', $value) . ')'; } return '(' . implode(', ', $keyNames) . ') IN (' . implode(', ', $vs) . ')'; }