$class = $r->newInstanceArgs($constructors);\r
}\r
\r
- $class->setId($row['id']);\r
+ $class->setId((int)$row['id']);\r
$entities[$row['id']] = $class;\r
}\r
\r
$queries = AbstractPopulationHelper::generateUpdateSaveQuery($this->_maps, $entity, $entity->getId(), $this->_db);\r
$mergeMap = array();\r
$flattened = array();\r
-\r
+ \r
foreach($queries as $index => $query)\r
{\r
$this_table = $query['table'];\r
\r
$queries[$index] = $query;\r
}\r
- \r
+\r
// if($queries['TYPE'] == AbstractPopulationHelper::QUERY_TYPE_CREATE)\r
// {\r
$idMap = [];\r
{\r
$mapsIndex = self::getMapsNameFromEntityObject($VO, $maps);\r
$table = $maps[$mapsIndex]['table'];\r
- \r
- $columns = array_merge(self::resolveColumnNamesAndValues($maps, $VO), $extraColumns);\r
- \r
+\r
+ //TODO: This may break everythign, but I _think_ if I pass extraColuns, it is always an id column.\r
+ //I also think that this method is only called when we are trying to work out a VO (NOT a VOArray)\r
+ //in which case there should be one unique row somewhere in the database that corresponds to the VO\r
+ //we want, in that case we can just find it by id. Throwing in more columns causes issues trying to\r
+ //update an existing VO because it uses the values of the current object, which we are trying to save,\r
+ //so it never finds the existing row and therefore makes a whole new one, which ruins everything.\r
+ if($extraColumns)\r
+ {\r
+ $columns = $extraColumns;\r
+ } else {\r
+ //I only had this before, I think I don't actually need to do this merge but I'm leaving it incase\r
+ $columns = array_merge(self::resolveColumnNamesAndValues($maps, $VO), $extraColumns);\r
+ }\r
+\r
$query = "SELECT * FROM $table where ";\r
\r
foreach($columns as $columnName => $columnValue)\r
}\r
\r
$query = substr($query, 0, -4);\r
+\r
$statement = $db->prepare($query);\r
$statement->execute();\r
$row = $statement->fetch();\r