fixes #20 (another change and fixfix)

This commit is contained in:
Steffen Vogel 2010-10-19 22:37:47 +02:00
parent ebb8ff96f3
commit 50e1d9dc13
3 changed files with 7 additions and 4 deletions

View file

@ -160,7 +160,7 @@ class EntityController extends Controller {
case 'boolean':
$value = ($value) ? 1 : 0;
}
$sqlWhere[] = 'EXISTS (SELECT p' . $i . ' FROM \Volkszaehler\Model\Property p' . $i . ' WHERE p' . $i . '.key = \'' . $property . '\' AND p' . $i . '.value = ' . $value . ' AND p' . $i . '.entity = a)';
$sqlWhere[] = 'EXISTS (SELECT p' . $i . ' FROM \Volkszaehler\Model\Property p' . $i . ' WHERE p' . $i . '.name = \'' . $property . '\' AND p' . $i . '.value = ' . $value . ' AND p' . $i . '.entity = a)';
$i++;
}

View file

@ -67,7 +67,7 @@ abstract class Entity {
/**
* @OneToMany(targetEntity="Property", mappedBy="entity", cascade={"remove", "persist"})
* @OrderBy({"name" = "ASC"})
* @OrderBy({"key" = "ASC"})
*/
protected $properties = NULL;

View file

@ -38,7 +38,7 @@ use Volkszaehler\Model;
* @Table(
* name="properties",
* uniqueConstraints={
* @UniqueConstraint(name="unique_keys", columns={"entity_id", "name"})
* @UniqueConstraint(name="unique_keys", columns={"entity_id", "pkey"})
* }
* )
* @HasLifecycleCallbacks
@ -53,7 +53,10 @@ class Property {
*/
protected $id;
/** @Column(name="name", type="string", nullable=false) */
/**
* @Column(name="pkey", type="string", nullable=false)
* HINT: column name "key" is reserved by mysql
*/
protected $key;
/** @Column(type="string", nullable=false) */