John Cartwright wrote:I think it boils down to whether your library can efficently handle all SQL statements. Until that day comes, and I've dabbled with my share of SQL generators, it is pointless to partially abstract away from SQL.
I dont think will ever accomplish that.what i tried to accomplish here was to express a Query using PHPs Syntax.And that syntax has got limitations,when it is applied in a database context.
John Cartwright wrote:it is pointless to partially abstract away from SQL. It simply doesn't make sense to me to abstract SQL generator only if I can use it sometimes and can be considered a code smell.
we use clay for sculptures..but why ,for buildings we use it in the form of bricks..?
I see no point in arguing about this anyway.It is a matter of personal preference,and I respect that.
John Cartwright wrote:Abstraction is meant to simplify, and not complicate. Therefore, if you are only solving simple SQL queries, you are not simplying anything since simple SQL statements are .. well .. simple.
by simplyfy,i meant it makes the work done using much shorter constructs.
select `user_name` from `users` where `id`=10
is a simple query a shorter version using the class would be
$db->users(10)->user_name
select `user`.`name` as `u_name` ,`product`.`name` as `p_name` from `user` as `u` join `product` as `p` on `p`.`user_id`=`u`.`id` where `u`.`id`='10'
is also a simple query...a shorter version could be
echo $db->_join->user('u')->product('p')->_end->u_id(10)->u_name
echo $db->_join->user('u')->product('p')->_end->u_id(10)->p_name
John Cartwright wrote: In fact, it only adds complexities (having to learn a new library) and inconsistencies to the code (raw sql and generated sql mixed)
It will defenitly lead to inconsistant code...i have no answers for that...but will you give up curly braces as block delimiters and prefer blocks to be defined using indenting ,so that resulting code will be beautifuly formatted and readable?
and why do we have `mysql_fetch_array` and `mysql_fetch_object` functions..?
Furthurmore, you need to be aware of the different SQL syntax, espaping, and other oddities using different SQL engines. I.e., Mysql vs Mssql on how they handle limit clauses.
My knowledge and experience is limited to MySQL only....
John Cartwright wrote:Sorry if that is discouraging, but good luck reguardless.
It is not discouraging..It just the kind of response I need...
But I would like to know if you had actually gone through the documentation...if you have not you can do it with out downloading the whole thing at
http://www.phpclasses.org/browse/file/26411.html
Thanks again for the comments...