From a41cd2bb0178cf4350e0b325dac53945bb1ea94f Mon Sep 17 00:00:00 2001 From: runa Date: Mon, 4 Jun 2007 18:47:26 +0000 Subject: [PATCH] support for unique columns in multikey tables --- lib/Doctrine/Validator/Unique.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Validator/Unique.php b/lib/Doctrine/Validator/Unique.php index e13cc0e65..e5dbf992b 100644 --- a/lib/Doctrine/Validator/Unique.php +++ b/lib/Doctrine/Validator/Unique.php @@ -42,7 +42,12 @@ class Doctrine_Validator_Unique public function validate(Doctrine_Record $record, $key, $value, $args) { $table = $record->getTable(); - $sql = 'SELECT ' . $table->getIdentifier() . ' FROM ' . $table->getTableName() . ' WHERE ' . $key . ' = ?'; + $pks = $table->getIdentifier(); + if ( is_array($pks) ) { + $pks = join(',',$pks); + } + + $sql = 'SELECT ' . $pks . ' FROM ' . $table->getTableName() . ' WHERE ' . $key . ' = ?'; $values = array(); $values[] = $value;