[TYPO3-core] RFC #15457: Add support for prepared queries

Jigal van Hemert jigal at xs4all.nl
Tue Aug 17 11:53:01 CEST 2010


Hi,

On 16-8-2010 22:21, Xavier Perseguers wrote:
> - We want to provide a PDO-like syntax but we don't aim at having a
> PDO-compatible implementation. We can provide enhancements and we should
> not fear having some goodies. We want to learn from Extbase (this is why
> I added some chaining feature for instance)

I could be wrong here, but the main reason to provide a PDO-like 
interface would be to take advantage of PDO in the end? This will 
simplify the tasks of DBAL considerably when it comes to communicating 
with the database(s).

We could build our own prepared-query-interface but this will be a PHP 
construction which will always be slower than PDO. To take advantage of 
the features and the speed of PDO it needs to be as compatible as possible.
Any time we create an incompatible feature we should ask ourselves if it 
is worth the resources it will cost.

For example, the PARAM_AUTO feature tries to guess the value type. Why 
should we have this. IMO it will cause more problems than it might 
solve. If you try to store a phone number and rely on the default 
PARAM_AUTO it will be put as a numerical value in the query and so it's 
interpreted in e.g. MySQL before storing it in a string type column.
The PDO default PARAM_STR would store it correctly, whether it's stored 
in a numerical or a string column in the database.
I'm not sure about how other databases handle this.

> - Removed bindParam() method (borrowed from PDO) because we do not like
> this way of programming and it hardly make sense in TYPO3. In PDO it is
> used mainly for getting back parameters. We do not have that in TYPO3.

For getting back parameters you would use bindColumn(). bindParam() is 
used for binding variables which might change between executing the same 
prepared statement and for binding variables which are supposed to be 
modified by the query (PDO::PARAM_INPUT_OUTPUT).

The fetching styles PDO::FETCH_CLASS and PDO::FETCH_INTO can also be 
useful to get data from the database into objects.

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh


More information about the TYPO3-team-core mailing list