Here’s some good documentation on PHP prepared statements and stored procedures including how to call stored procedures with output parameters.
Tag Archives: php
Do you need to call PDOStatement::closeCursor when you’re done with the statement?
The answer is no, so long as you’re not preparing to execute the statement again. I figured this out by looking at the code for PDOStatement::closeCursor and the MySQL implementation. Seems to me that all the freeing necessary is done in the destructor so if you’re not planning to use the statement again it seems to me that you can safely omit the call to PDOStatement::closeCursor(). On the other hand if you are going to reuse the statement calling closeCursor seems like it’s a pretty important thing to do. It would be nice if PDOStatement::fetchAll() called closeCursor() for us, but I don’t think it does.
Surprisingly Slow
Some good points here: Surprisingly Slow. I’m thinking about installing zstandard for my PHP… see Better Compression with Zstandard for some numbers.
PDOStatement::fetchAll
There’s some really good PHP PDO documentation over here: PDOStatement::fetchAll. Of particular interest were PDO::FETCH_KEY_PAIR, PDO::FETCH_PROPS_LATE, PDO::FETCH_GROUP, and PDO::FETCH_FUNC.
PHP finally blocks not run on exit
I confirmed with the following code that if you call ‘exit’ withing a ‘try’ block the ‘finally’ block does *not* execute. That’s probably what you would expect. But now we know.
register_shutdown_function( 'handle_shutdown' ); try { exit; } catch ( Exception $ex ) { echo "caught...\n"; } finally { echo "finally...\n"; } function handle_shutdown() { echo "shutdown...\n"; }
Enabling XDebug for PHP under Apache2
Putting these settings in /etc/php/7.2/apache/php.ini did the job:
[XDebug] xdebug.profiler_enable = 1 xdebug.profiler_output_dir = /tmp/xdebug xdebug.profiler_output_name = cachegrind.out.%p.%u.%H.%R.xt
The cachegrind files are now written to /tmp/xdebug.
AWS SDK for PHP
Today I learned about AWS SDK for PHP. Haven’t actually used it.
Generating unique, random-looking voucher codes
Today I discovered Generating unique, random-looking voucher codes.
What’s New in PHP 8
This on r/programming today: What’s New in PHP 8.
How to generate an SSL private key for use with MySQL/MariaDB and PDO
To generate an SSL private key for use with MySQL/MariaDB and PDO:
openssl genrsa -out client-key.pem 4096