I'm writing a .sql file using Perl, not writing to the mysql database directly. I need to quote the strings in that file. Looks like the $dbh-quote() method does what I want. Except that I can't figure out how to use it without a database connection. I'd make a dummy connection, but I can't seem to do this without a database running, and the machine that is going to run this cron job won't have one.
This question is similar: Perl DBI without accessing the database and the accepted answer states that "You might attempt to load the driver you need and call the function directly", which is what I would like to do, but I can't figure out how to do that.
Reliable quoting requires that the driver understand the character set/collation of the connection as escaping varies based on that information.
This is why in PHP mysql_escape_string() was replaced with mysql_real_escape_string(), which uses the database connection properties to properly escape input strings.
Sounds like you're going to have to figure out what quote
does and implement it yourself. Not having access to a real DB connection is likely going to be a show-stopper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With