[SQLHat] Proposal
| From: | Kamen TOMOV | Date: | Mon, 05 Apr 2004 18:31:34 +0000 |
| Subject: | [SQLHat] Proposal | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-27066@lists.php.net to get a copy of this message | ||
Hello!
I've developed something and I would like to tell you about it so that
you consider the possibility to add it to PEAR.
It is called SQLHat and it is a class-library. It goes together with a
viewer/tester called SQLHatViewer. It's currently hosted on the GNA!'s
web site and it is GPL-licensed.
Here is more 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:
https://gna.org/projects/sqlhat
http://cvs.gna.org/viewcvs/sqlhat/sqlhat/
http://cvs.gna.org/viewcvs/sqlhat/sqlhat-viewer/
Thank you for your attention.
Regards,
--
Kamen A. TOMOV
:. http://www.cybuild.com/ .: