- //XXX: This whole biz is tricky. Basically the problem is that when creating a new simfile,\r
- //the datamapper spews out a bunch of create queries. When parsing a simfile for example, there can\r
- //be huge redundency - it may produce 5 queries that all create the same step artist, for example.\r
- //We attempt to flatten equivalent queries. Originally I was basing it purely on the table name or something,\r
- //but that is not enough. In the case of steps, it ends up mergin all the steps together, so we need to\r
- //check if the arrays are equal as well, which is what this does.\r
- if($this_columns === $queries[$i]['columns'])\r
- {\r
- //need to keep track of what we merged as future queries might reference the old ids.\r
- $mergeMap[$i] = $index;\r
- }\r
- \r
- //XXX: Another thing that might happen is we have to create queries running on the same table, but with unique columns.\r
- //In this case, we can take the columns of one and put it into the other. Otherwise we create two records when we really\r
- //should have only one. An example of this is when a user is created, a query to add the country to users_meta is run,\r
- //and then _another_ to add firstname, lastname and user_id. It should really all be done in one query.\r
- \r
- //Make sure both queries are for the same table, and the both relate back to the main query\r
- if($this_table == $queries[$i]['table'] && in_array('%MAIN_QUERY_ID%', $this_columns) && in_array('%MAIN_QUERY_ID%', $queries[$i]['columns']))\r
+ if(\r
+ $queries[$i]['table'] == $this_table &&\r
+ !array_key_exists($i, $mergeMap) &&\r
+ !isset($query['id'])) //only merge create queries, updates are fine to run multiple times\r