EllisLab/CodeIgniter — pull request #1100 by rrdial (2012-03-01 22:45:24+00:00)
Title: 2.1-stable: bug fix: 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.

see discussion on https://github.com/EllisLab/CodeIgniter/pull/1098 and https://github.com/EllisLab/CodeIgniter/pull/1099