From: Chuck Hagenbuch Date: Thu, 12 Mar 2009 17:57:21 +0000 (-0400) Subject: cast primary key to string where necessary X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=aec515b103f685f90acb5bc7624994d10aaaa956;p=horde.git cast primary key to string where necessary --- diff --git a/framework/Rdo/lib/Horde/Rdo/Mapper.php b/framework/Rdo/lib/Horde/Rdo/Mapper.php index 7fc180a60..646e84753 100644 --- a/framework/Rdo/lib/Horde/Rdo/Mapper.php +++ b/framework/Rdo/lib/Horde/Rdo/Mapper.php @@ -345,7 +345,7 @@ abstract class Horde_Rdo_Mapper implements Countable $id = $this->adapter->insert($sql, $bindParams); - return $this->map(array_merge(array($this->tableDefinition->getPrimaryKey() => $id), + return $this->map(array_merge(array((string)$this->tableDefinition->getPrimaryKey() => $id), $fields)); } @@ -364,7 +364,7 @@ abstract class Horde_Rdo_Mapper implements Countable public function update($object, $fields = null) { if ($object instanceof Horde_Rdo_Base) { - $key = $this->tableDefinition->getPrimaryKey(); + $key = (string)$this->tableDefinition->getPrimaryKey(); $id = $object->$key; $fields = iterator_to_array($object); @@ -396,7 +396,7 @@ abstract class Horde_Rdo_Mapper implements Countable $sql .= ' ' . $this->adapter->quoteColumnName($field) . ' = ?,'; $bindParams[] = $value; } - $sql = substr($sql, 0, -1) . ' WHERE ' . $this->tableDefinition->getPrimaryKey() . ' = ?'; + $sql = substr($sql, 0, -1) . ' WHERE ' . (string)$this->tableDefinition->getPrimaryKey() . ' = ?'; $bindParams[] = $id; return $this->adapter->update($sql, $bindParams); @@ -414,13 +414,13 @@ abstract class Horde_Rdo_Mapper implements Countable public function delete($object) { if ($object instanceof Horde_Rdo_Base) { - $key = $this->tableDefinition->getPrimaryKey(); + $key = (string)$this->tableDefinition->getPrimaryKey(); $id = $object->$key; $query = array($key => $id); } elseif ($object instanceof Horde_Rdo_Query) { $query = $object; } else { - $key = $this->tableDefinition->getPrimaryKey(); + $key = (string)$this->tableDefinition->getPrimaryKey(); $query = array($key => $object); } @@ -470,7 +470,7 @@ abstract class Horde_Rdo_Mapper implements Countable if (is_numeric(key($arg))) { // Numerically indexed arrays are assumed to be an array of // primary keys. - $key = $this->tableDefinition->getPrimaryKey(); + $key = (string)$this->tableDefinition->getPrimaryKey(); $query = new Horde_Rdo_Query(); $query->combineWith('OR'); foreach ($argv[0] as $id) {