Commit b7bf2265 authored by doctrine's avatar doctrine

enhanced InvalidKeyException messages

parent d0528260
......@@ -38,11 +38,11 @@ class Doctrine_Query extends Doctrine_Hydrate {
$where = $this->where;
$having = $this->having;
$q = "SELECT COUNT(1) FROM ".$table." ";
$q = "SELECT COUNT(1) FROM ".$table->getComponentName()." ";
foreach($join as $j) {
$q .= implode(" ",$j);
}
$string = $query->applyInheritance();
$string = $this->applyInheritance();
if( ! empty($where)) {
$q .= " WHERE ".implode(" AND ",$where);
......@@ -56,7 +56,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
if( ! empty($having))
$q .= " HAVING ".implode(' AND ',$having);
$a = $this->table->getSession()->execute($q, $params)->fetch(PDO::FETCH_NUM);
$a = $this->getSession()->execute($q, $params)->fetch(PDO::FETCH_NUM);
return $a[0];
}
/**
......
......@@ -398,7 +398,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/
final public function getBound($name) {
if( ! isset($this->bound[$name]))
throw new InvalidKeyException();
throw new InvalidKeyException('Unknown bound '.$name);
return $this->bound[$name];
}
......@@ -414,7 +414,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
return $this->bound[$k];
}
}
throw new InvalidKeyException();
throw new InvalidKeyException('Unknown bound '.$name);
}
/**
* returns the alias for given component name
......@@ -438,7 +438,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
if($name = array_search($this->boundAliases,$alias))
return $name;
throw new InvalidKeyException();
throw new InvalidKeyException('Unknown alias '.$alias);
}
/**
* unbinds all relations
......@@ -480,7 +480,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/
final public function bind($name,$field,$type,$localKey) {
if(isset($this->relations[$name]))
throw new InvalidKeyException();
throw new InvalidKeyException('Relation already set for '.$name);
$e = explode(" as ",$name);
$name = $e[0];
......@@ -540,6 +540,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return Doctrine_Relation
*/
final public function getForeignKey($name) {
$original = $name;
if(isset($this->relations[$name]))
return $this->relations[$name];
......@@ -614,7 +616,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$this->relations[$alias] = $relation;
return $this->relations[$alias];
}
throw new InvalidKeyException();
throw new InvalidKeyException('Unknown relation '.$original);
}
/**
* returns an array containing all foreign key objects
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment