[SQLHat] Proposal
| From: | Kamen TOMOV | Date: | Tue, 06 Apr 2004 18:20:18 +0000 |
| Subject: | [SQLHat] Proposal | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-529@lists.php.net to get a copy of this message | ||
Hello!
I just subscribed to pecl-dev mailing list after discussing the
library that I've created on the pear-dev's mailing list.
It's about a piece of software called SQLHat. SQLHat is a class
library that goes together with a viewer/tester, both of which are
currently written in PHP.
I'm considering the possibility to rewrite the library as a PHP
extension in "C" and to leave the viewer as it is except by
integrating it with the MDB library.
Here is some information from the SQLHat's README file.
NAME:
SQLHat - SQL-queries wrapper
SYNOPSIS:
require 'SQLHat.php';
$hl = SQLHat::getInstance("sql/query.sql");
$params['lbound'] = 29;
$params['rbound'] = 32;
$query = $hl->process($params);
DESCRIPTION:
What is SQLHat?
SQLHat is a library and a test tool and it suggests a better
aproach for quering databases with SQL queries.
The traditional aproach is embedding the queries in the program by
assigning them to variables as strings. It has several
disadvantages:
First of all this way we have to mix the program code with the SQL
code. We have to pay atention to quotes and we usually can not use
capabilities of an advanced editior such as syntax highlighting
for the SQL code.
Second of all there is no easy way to test the query without
testing the program code. In order to test the query we have to
copy it and paste it somewhere. The problem gets even bigger if
this query contains parameters. In that case we have to edit it
before even trying to execute.
Finally if the language we use needs to be compiled each time we
change the query we have to recompile the program.
The suggested approach solves this problems and adds additional
features that make the programming easier and faster.
Testing the queries without testing of the rest of the code is
possible because we isolate them in separate program files - each
one in different .sql file.
SQLHat allows using parameters in the queries and introduces 3
parameter type definitions - string, int and float parameters.
The last thing we add is the opportunity to wrap fragments of the
query in blocks and to include them conditionally depending on the
value of a condition.
Here is an example of the capabilities that SQLHat provides:
Example 1. SQLHat query
~~~~~~~~~~~~~~~~~~~~~~~
string $status, $hair, $eyes
int $age
condition $I_CARE
SELECT name, phone
FROM all_girls
WHERE
makes_love_with = 'men'
AND status = $status
AND hair = $hair
AND eyes = $eyes
IF $I_CARE
AND age = $age
ORDER BY age
ENDIF
SQLHat is from two parts. The first one is the library. It
allows using SQLHat-queries. The second part is the
query tester. Currently it's possible to test a query and to see
the results in a table on the web browser.
SQHat should be available in various programming languages (PHP,
Perl, Python, Java,...) and should work with any databases.
COPYRIGHT:
Copyright (C) 2003 Kamen TOMOV. All rights reserved.
This software is distributed under the terms of the GNU General Public License.
Please read the disclaimer at the top of the SQLHat.php file.
You can download the library and the viewer from the GNA!'s CVS. Here
are some links:
The project's main site:
https://gna.org/projects/sqlhat
http://cvs.gna.org/viewcvs/sqlhat/sqlhat/
http://cvs.gna.org/viewcvs/sqlhat/sqlhat-viewer/
Here are some links to the discussion on the pear-dev's list:
http://news.php.net/article.php?group=php.pear.dev&article=27078
http://news.php.net/article.php?group=php.pear.dev&article=27087
http://news.php.net/article.php?group=php.pear.dev&article=27090
Thank you for your attention and thanks in advance for your comments.
Regards,
--
Kamen A. TOMOV
:. http://www.cybuild.com/ .: