thekid/rfc — Issue #118: RFC 0118: Exceptions for missing token values in StatementFormatter
Author: thekid
Created: 2011-10-09 15:13:00+00:00
State: open

Scope of Change
====
The DBConnection::query/select/insert/update/delete methods will throw
an exception in case one of their format args is missing.

Rationale
====
Prevent accidentally missing arguments leading to incorrect data being
written to the database.

Functionality
====
The following used to work and would send "Hello NULL" to the database:

```php
query('Hello %s'); // No arguments
$db->query('Hello %2$s', 'Timm'); // Beyond sizeof arguments
?>
```

These will now raise an rdbms.SQLStateException.

Note
----
This is consistent with [v?s]printf(), which will raise a warning and
return NULL (the PHP way of indicating errors in procedural APIs) when
arguments referenced in the format string are missing.

Security considerations
====
n/a

Speed impact
====
Slightly slower because of isset() -> array_key_exists() changes.
isset($array[5]) will return FALSE if $array= array(5 => NULL)!

Dependencies
====
n/a

Related documents
====
- http://xp-framework.net/rfc/contrib/rfc0118.diff
Implementing patch

Comments
====