EllisLab/CodeIgniter — pull request #1098 by rrdial (2012-03-01 20:27:57+00:00)
Title: 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.