The main issue that I see with that suggested syntax is differentiating between literal query text and the cfqueryparam
Micha will be able to tell us if that is feasible.
Igal
--
typos, misspels, and other weird words brought to you courtesy of my mobile device.
So, maybe combine both as suggested above and merge the 2 approaches:
query name="r" {
select * from table where id= :param1
and cus_id= :param2;
queryparam name=":param1" value="#value# cfsqltype="cf_sql_integer";
queryparam name=":param2" value="#value2# cfsqltype="cf_sql_integer";
}
which is exactly what Peter Boughton suggested but then in CFSCRIPT notation. Would work for me
Or variation:
query name="r" {
select * from table
where
id= <queryparam value="#value# cfsqltype="cf_sql_integer"> and
sec_id= id= <queryparam " value="#value2# cfsqltype="cf_sql_integer">
}
if this doens't give any parsing issues?
Cheers
Micha, what about my suggestion? It doesn't need a "new language", just a different way of handling tags "within" cfscript ;)
I did an analysis of the number of characters typed, and the E4X style uses fewer characters than Railo's implementation (see the blog post). It's also much easier to read because you don't have writeOutput() calls all over the place, and editors would be able to perform better syntax highlighting on the SQL keywords because the code isn't trapped inside a string.
Those are all pretty big failings of what the CFML Advisory agreed on, which IMO is why people want a better solution :P
Just my 2 cents.
Cheers,
Justin
But mixing the two seems creating a very old child which i don't think is initiative for new developers to pick up, isn't cfscript strange enough.Is this really what the community is crying out for ? I thought cfquery and cfqueryparam where one of the nicest things of CFmy2pA
I'm not sure how that could work because it would just be seen as a string.
The tags aren't just for consistency, it's necessary to have a syntax that could be parsed and not mistaken for code that has some alternative meaning (such as being interpreted just as a string). In addition, you also need to be able to use logic to build dynamic queries. But, consistency is a good reason for implementing queries in script in this way, because it's how we've always written queries in the past, and it just happens to be very readable and very concise as well :)
Cheers,
Justin
qPerson = <cfquery>
SELECT * from people
WHERE name = <cfqueryparam cfsqltype="cf_sql_varchar" value="Bob">
</cfquery>;