A simple class that goes through a specified folder and lists all files, triggering a class event every time a new file has been found and a different event when a folder is found. You concentrate on what you need to do with the files. There were many dir classes out there but none which could do what I wanted, this is why I release this one. Released as sharewear (see readme file) which is my own version of freeware.
This package can be used to parse and compose SQL queries programatically.
It can take an SQL query and parse it to extract the different parts of the query like the type of command, fields, tables, conditions, etc..
It can also be used to do the opposite, i.e. compose SQL queries from values that define each part of the query.
Features:
I. Parser
- insert
- replace
- update
- delete
- select
- union
- subselect
- recognizes flow control function (IF, CASE - WHEN - THEN)
- recognition of many sql functions
II. Composer (Compiler)
- insert
- replace
- update
- delete
- select
- union
III. Wrapper SQL
- object oriented writing of SQL statements from the scratch
#################################################
a more advanced example:
#################################################
$sql = 'SELECT
countrylanguage.CountryCode,
country.Name,
country.Continent,
country.Region,
country.SurfaceArea,
city.District,
country.IndepYear,
country.Population,
city.CountryCode,
city.Name,
city.Population,
countrylanguage.Language AS lang,
countrylanguage.IsOfficial,
countrylanguage.Percentage,
country.GovernmentForm,
country.LocalName,
country.GNPOld,
country.GNP,
country.LifeExpectancy
FROM
country co
LEFT JOIN city ct ON co.Code = ct.CountryCode
LEFT JOIN countrylanguage cl ON cl.CountryCode = ct.CountryCode
WHERE
(co.Continent='Asia' AND cl.Language='Pashto')
GROUP BY
co.Name
HAVING
ct.CountryCode = 'AFG'
LIMIT 100
':
// using wrapper class
$sqlDef = new Sql();
$sqlDef->parse($sql);
echo $sqlout;
#################################################
SELECT countrylanguage.CountryCode, country.Name, country.Continent, country.Region, country.SurfaceArea, city.District, country.IndepYear, country.Population, city.CountryCode, city.Name, city.Population, countrylanguage.Language AS lang, countrylanguage.IsOfficial, countrylanguage.Percentage, country.GovernmentForm, country.LocalName, country.GNPOld, country.GNP, country.LifeExpectancy
FROM country AS co
LEFT JOIN city AS ct ON co.Code = ct.CountryCode
LEFT JOIN countrylanguage AS cl ON cl.CountryCode = ct.CountryCode
LEFT JOIN employees ON employees.employeeID = 1
WHERE (co.Continent = 'Asia' and cl.Language = 'Pashto')
GROUP BY co.Name
HAVING ct.CountryCode = 'AFG'
LIMIT 0,100
#################################################
IV. Hint
Sql_Compiler is none validating, but throws errors on type mismatch or corrupt statements
Note:
If you have good ideas to improve this set of classes, let me know.
Acknowledgement:
Thanks a lot to George Antoniadis (Author: rephp framework, www.rephp.net) from noodles.gr for his qualified feedback.
Many thanks to all, which gave me qualified feedback and voted for this set of classes at the contest.
This class can be used to redirect requests based on URL rewriting rules.
It can check whether the current request URL matches one or more rules.
If one of the defined rules is matched, the class determines the path of a PHP script that will handle the request and executes that script using the PHP require command.
If none of the rules matches, the class include the default error script and returns the 404 status code to the browser.
A class to search text in pdf documents.
Not pretending to be useful other than that.
But it can easily be extended to a full featured pdf document
parser by anyone who chooses so.