Ok, well prepared statements to me mean that the SQL engine has
pre-compiled the SQL which is something MySQL doesn't support.
If all you want is an easier way to manage your queries using placeholders
it seems like a pretty trivial little thing to do in user space.
eg.
function execute() {
$argc = func_num_args(); $args = func_get_args();
$parts = explode('?',$args[0]);
for($i=1,$sql=$parts[0];$i<count($parts);$i++) {
$str = (gettype($args[$i])=='string') ? ("'".addslashes($args[$i])."'") :
$args[$i];
$sql.=$str.$parts[$i];
}
return $sql;
}
$sql = "update user_list set first_name = ? where id = ?";
echo execute($sql,'andrew',1);
Try running that little 60-second hack job. Seems to do most of what you
just described. Put another 10 minutes of work into it and you are there.
-Rasmus
> for example in PERL DBD::mysql you can prepare statements like so:
>
> $sql = "update user_list set first_name = ? where id = ?"
> $han = $dbh->prepare($sql);
>
> $han->execute('andrew',1);
> $han->execute('bill',2);
> ....
>
> this is a very useful thing that's implemented in a lot of different
> languages (PERL, Java... )and i thought people might get a lot of use out
> of it in php...
> it abstracts the details of escaping strings, enclosing them in single
> quotes, and type checking from the developer to make things easier. it
> also speeds up execution in some circumstances.
>
>
> At 06:59 PM 10/26/01 -0700, you wrote:
> > > i'd like to get people's feedback on the possibility/ feasibility of
> > > implementing prepared statements in php for atleast MySQL and perhaps
> > > more. i'm new to the list, so maybe you've already discussed this. i'd
> > > like to start developing something like this soon unless someone else is
> > > already working on it. thanks!
> >
> >Prepared statements isn't something you implement in a scripting language.
> >It is something that needs to be implemented in the SQL server itself.
> >What exactly would you be "preparing" in PHP space?
> >
> >-Rasmus
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]