Displaying BLOB PDF File

That looks like it is a template file. If so, the function add_header_info is hooked into send_headers long after send_headers had fired. You will need to move that code so that it executes earlier. It should work from a mu-plugin file, a plugin file or from your theme’s functions.php. However, $FileType and those other variables … Read more

How to get the SQL of the changes made to the database from an update or upgrade?

Log queries: You could collect all the queries during core/plugin/theme upgrades to see what happens. Just follow these two steps: 1) You should add: define( ‘SAVEQUERIES’, TRUE ); to your wp-config.php file to collect all queries during a page load into the $wpdb->queries array. Just remember to remove it afterwards. 2) Then you could log … Read more

Select two sums with single get_var statement

$wpdb->get_var will do exactly what the name suggests– return a single value. So this: $sum = $wpdb->get_var(“select sum(first), sum(second) from sums_test where id > 1”); var_dump($sum); Will return the result of sum(first). The rest of the result is lost (though cached I believe). The method you want is get_row which will return a complete row … Read more

$wpdb doesn’t like to store arrays

Don’t store serialised PHP data in the database! It can be a major security risk! When the contents of the value are deserialised, any objects get recreated and their constructors and wakeup methods run, this can be used to launch an attack. Additionally, that data can’t be search replaced, because PHP serialised strings contain values … Read more