- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Run a trace on an update statement from your thoroughly clever Linq to Sql. It writes writes individual update statements for each of the records in your set. Databases are much quicker at running one statement that updates 100 records rather than 100 statements that modify one record each.
Admin
Straw man? L2S will issue single statements as programmed, as this is its primary purpose. However it allows you to create batch statements through expression trees (and probably other ways too) as below:
http://www.aneyfamily.com/terryandann/post/2008/04/Batch-Updates-and-Deletes-with-LINQ-to-SQL.aspx
Of course I'll be the first to admit to breaking out the SQL as needed when I figure it's a better bet, but L2S or EF are great bets in my book for taking out a fair bit of donkey work.
Admin
Stripping out valid characters tis not the answer as ye prevent half of Ireland from entering their proper surname.
Proper escaping will work most times, prepared statements will always work.
For the last time, my name is not ONeil!
Admin
What does this have to do with the rings around uranus and being friskted?
cptchah -conventio- conventional in and out put
Admin
Let's assume your proof is correct. Have you considered replacing the language, rather than the use of prepared statements (I'll kindly assume that this is what you meant by "stored procedures")?
Well, perhaps you do mean "stored procedures." Perhaps, in that case, you could explain where a "stored procedure" is horrible and brittle and a "PHP procedure" is not?
It's that naughty "security" thing getting in the way again, isn't it?
Of course, you could always ask a DB Admin to do the dump for you. Which is the rather more common case, and doesn't have anything at all to do with "stored procedures" or "prepared statements."
One table? CRUD? OK, fine. But try anything more complicated, with user input and calculations and string concatenation and stuff, and you are going to blow your foot off.
Let me remind you of the universal dictum: Get It Provably Correct first. Then worry about optimizations.
Up a couple of levels? Nice idea. "Hey boss, we just lost $1 million on a SQL injection. But, on the other hand, I'm l33t!"
Admin
I don't like programmers who can't escape their strings properly.
Admin
Admin
Only an idiot would use a regexpression to prevent an SQL injection attack.
SQL injection attacks are best targeted and negated in the SQL , not by trying to sanitize the input in a half assed way. A good start would be the use of SQL bind variables, instead of string concatenation.
Admin
There's a compromise, though. What is helpful is a framework that allows you to write the SQL, then does the parametrization and wrapping for you, to give you access classes.
We use a framework that creates a wrapper class around a user-specified query, so that selects basically become something like:
That's just a sketch, but the idea should be clear. The point is that what you're (rightfully) rejecting is frameworks that try to help you too much.
Computers are dumb. Good SQL takes intelligence. A good wrapper class around good SQL can be groveled out by something dumb, and help enormously with the interface between good code and good SQL.
Admin
I thought this was a best practice in the PHP community? It certainly is with all the Pretend Home Programming aficionados I've had the misfortune to encounter.
Admin
418 - I'm a teapot
http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#418_Im_teapot
Admin
Admin
Every developer should know that parameterised queries are the way to go. Good that PHP supports them.
I once tried to sign up to a web site of a company that claimed to be an expert in computer security. The site rejected my application form because my name "looked like an SQL injection attack". My name, "Corfield". We narrowed it down to the word "field", then decided not to talk to the company in question about web security.
Admin
It depends on your developers. We had an in-house framework for SQL generation and yes it was inefficient, but productivity was really good. Thing is, we then spent some time improving it. Now the generated SQL works really well and we have some nice speed benefits, but the hand coded stuff did not benefit.
We also benefit from things like Unit of Work, which lets us perform JDBC batching which really helps.
I've also worked with stored procedures, lower layers in PLSQL. Each to their own I suppose. I value the developer productivity of the object mapping layer, and have seen it work on some quite high volume systems.
Admin
how is the prepared statement more safe...you're passing the email (POST) variable without checking what's in it, in both cases.