From f5f3b0d27adeeabe5b0a9a12150cb1ba21b03050 Mon Sep 17 00:00:00 2001 From: doctrine Date: Mon, 5 Jun 2006 10:24:14 +0000 Subject: [PATCH] Support for uppercase columns --- Doctrine/Query.php | 10 +++------- Doctrine/Record.php | 2 +- Doctrine/Session.php | 4 ++-- tests/classes.php | 26 ++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Doctrine/Query.php b/Doctrine/Query.php index 6ee2de712..e2afe5727 100644 --- a/Doctrine/Query.php +++ b/Doctrine/Query.php @@ -422,7 +422,7 @@ class Doctrine_Query extends Doctrine_Access { $array = $this->parseData($stmt); - $colls = array(); + $colls = array(); foreach($array as $data) { /** @@ -509,11 +509,7 @@ class Doctrine_Query extends Doctrine_Access { */ public function parseData(PDOStatement $stmt) { $array = array(); - $keys = array(); - foreach(array_keys($this->tables) as $key) { - $k = strtolower($key); - $keys[$k] = $key; - } + while($data = $stmt->fetch(PDO::FETCH_ASSOC)): /** * parse the data into two-dimensional array @@ -522,7 +518,7 @@ class Doctrine_Query extends Doctrine_Access { $e = explode("__",$key); if(count($e) > 1) { - $data[$keys[$e[0]]][$e[1]] = $value; + $data[$e[0]][$e[1]] = $value; } else { $data[0][$e[0]] = $value; } diff --git a/Doctrine/Record.php b/Doctrine/Record.php index bdbc932e5..f9fb72527 100644 --- a/Doctrine/Record.php +++ b/Doctrine/Record.php @@ -143,7 +143,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } // get the data array $this->data = $this->table->getData(); - + // get the column count $count = count($this->data); diff --git a/Doctrine/Session.php b/Doctrine/Session.php index 2eb78e5e0..e917d1010 100644 --- a/Doctrine/Session.php +++ b/Doctrine/Session.php @@ -80,9 +80,9 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab $this->dbh = $pdo; $this->state = Doctrine_Session::STATE_OPEN; - $this->setParent($manager); + $this->setParent($manager); - $this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); + $this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL); $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); switch($this->getAttribute(Doctrine::ATTR_CACHE)): diff --git a/tests/classes.php b/tests/classes.php index 25f516498..1178553de 100644 --- a/tests/classes.php +++ b/tests/classes.php @@ -272,6 +272,32 @@ class ORM_TestItem extends Doctrine_Record { $this->hasOne("ORM_TestEntry", "ORM_TestEntry.itemID"); } } +class ORM_AccessControl extends Doctrine_Record { + public function setTableDefinition() { + $this->hasColumn("name", "string", 255); + } + public function setUp() { + $this->hasMany("ORM_AccessGroup as accessGroups", "ORM_AccessControlsGroups.accessGroupID"); + } +} + +class ORM_AccessGroup extends Doctrine_Record { + public function setTableDefinition() { + $this->hasColumn("name", "string", 255); + } + public function setUp() { + $this->hasMany("ORM_AccessControl as accessControls", "ORM_AccessControlsGroups.accessControlID"); + } +} + +class ORM_AccessControlsGroups extends Doctrine_Record { + public function setTableDefinition() { + $this->hasColumn("accessControlID", "integer", 11); + $this->hasColumn("accessGroupID", "integer", 11); + + $this->setPrimaryKey(array("accessControlID", "accessGroupID")); + } +} class Log_Entry extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn("stamp", "timestamp");