EllisLab/CodeIgniter — pull request #1099 by rrdial (2012-03-01 21:19:10+00:00)
Title: 2.1-stable: compile binds before caching the query…

… otherwise the cached query will never match the unboud query
Currently, with database caching on, a query such as:

```php
$this->db->query('SELECT `fields` FROM `table` WHERE `key` = ?', array('value'));
```

will check the cache for

```mysql
SELECT `fields` FROM `table` WHERE `key` = ?
```

then perform the bind, then cache the query as

```mysql
SELECT `fields` FROM `table` WHERE `key` = 'value'
```

My change simply moves the bind above the cache check so the cached query is actually found.

New pull request for the 2.1-stable branch.