4 ms·
To be fair to PHP, a lot of other languages had bad examples around as well. Pretty much every language has a way to do string interpolation on untrusted input
by tyingq 5y ago
To be fair to PHP, a lot of other languages had bad examples around as well. Pretty much every language has a way to do string interpolation on untrusted input and pass it to to a database .
- kaba0 5y ago> Pretty much every language has a way to do string interpolation on untrusted input and pass it to to a database Otherwise they would not be Turing complete.. but defaults/easiest route does matter very much in this case.
- SilverRed 5y agoAnd the default docs and tutorials. If you look at Ruby on Rails. The way every tutorial will show makes it impossible to get an sql injection. Then as you gain more skill you will eventually find the function that lets you run a string query but no guide or tutorial shows you this so it is less likely you will use it without understanding.
- codedokode 5y agoRuby and Rails tutorial is not a Ruby tutorial. The ancestor comment talked about language tutorials, not framework tutorials.
- kaba0 5y agoJDBC does have an option to pass parameters without doing string interpolation and I would not consider it a framework.
- tyingq 5y agoI don't mean going through hoops. String interpolation is easy in most languages. See https://news.ycombinator.com/item?id=27958651 https://news.ycombinator.com/item?id=27958651 for example.
- flomo 5y agoJava and C# 1.0 examples (mostly) did not have anything like this, because they shipped with a database layer (JDBC/ADO.net) and not just a raw driver. PHP instead spent many years fucking around with hacks like addslashes() and etc before addressing the root issue.
- deleted 5y ago[deleted]
- tyingq 5y agoJava ones were pretty easy for me to find... String insertQuery = "insert into student values('" + studentNo + "','" + studentName +"','"+ studentAddress + "','"+studentAge+"')"; int result = statement.executeUpdate(insertQuery); https://www.onlinetutorialspoint.com/jdbc/jdbc-insert-program-example.html https://www.onlinetutorialspoint.com/jdbc/jdbc-insert-progra... Result #5 on Google for: jdbc insert program example And this one, #1 for "jdbc example variable where" on Google: String query = "select LastModified from CacheTable where " + " URL.equals(url)"; https://stackoverflow.com/questions/2608376/specifying-a-variable-name-in-query-where-clause-in-jdbc https://stackoverflow.com/questions/2608376/specifying-a-var...