Re: [SQLHat] Proposal
| From: | Kamen TOMOV | Date: | Tue, 06 Apr 2004 12:50:26 +0000 |
| Subject: | Re: [SQLHat] Proposal | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-27087@lists.php.net to get a copy of this message | ||
Thanks for the comment!
On Tue, Apr 06, 2004 at 11:33:31AM +0200, Lukas Smith wrote:
> Sounds like a good idea.
> However it seems to be you can reach this level of "abstraction" very
> easily with PHP.
>
> You simply place your queries in external files which you then include
> in your code.
>
> This would provide all the described benefits without requiring any
> other changes, leaving the choice of API to use total open.
>
> It would also allow to write a browser for all of these files and then
> run the queries with the given parameters.
I have considered that idea and I didn't choose to do that for several
reasons. The main one is that I want SQLHat available to other
programming languages and not only the library itself but also the
queries. I want if somebody decide to migrate from PHP to Python or
Perl, or Java, or whatever to be able to keep the .SQL queries intact.
> Obviously using PHP syntax inside the files would mean that for
> other languages you would have to parse the files, but you seem to
> be doing this right now already so I dont see a new disadvantage
> there.
Yes, things like "<?php" and "?>" can be parsed if they were in the
.SQL files but it seems weird to me to do so when using Java for
example.
> Using PHP would also allow for some more complex things inside the
> files, which should probably discouraged, but will ensure that you
> dont suffer from any limitations from some custom scripting language
> (which right now only does parameter replacements and if's it seems
> (?)).
Actually it's not a custom scripting language - it's a hat, SQL's hat
:) Yes you're right I have only "IFs" there in addition to parameter
definitions. This pseudo-code, even if a reason to extend it shows up,
should stay closer to SQL than to any other language and that is an
additional reason why I wouldn't decide to use more complex PHP or
other syntax inside the .sql files.
> Beyond that there would be the advantage of reducing the overhead as
> normal PHP files would also be cached using standard PHP bytecode
> caches (remember that reading files is not an insignificant overhead
> otherwise).
This is one of my concerns and a reason why I am considering the idea
to rewrite SQLHat in "C" as a PHP extension. Probably the sql files
could be cached the way PHP-files are cached.
As a matter of fact I was also considering the idea to suggest to the
database managers's producers like MySQL, PostgreSQL or Oracle to
adopt the idea but it seems not very likely that all they would do
so. That's why I need SQLHat independant not only from the programming
language but also from the database.
Regards,
--
Kamen A. TOMOV
:. http://www.cybuild.com/ .: