Skip to content

Instantly share code, notes, and snippets.

@czenzel
Last active September 27, 2019 11:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czenzel/2fc95098f61b7fd8714717ddaee80089 to your computer and use it in GitHub Desktop.
Save czenzel/2fc95098f61b7fd8714717ddaee80089 to your computer and use it in GitHub Desktop.
WordPress SQLite Integration Extensions and Fixes
<?php
/*
Plugin Name: SQLite Query Fixes
Description: Custom SQLite Fixes for Wordpress and SQLite Integration
Author: Christopher Zenzel
Version: 1.0
*/
add_filter('query', 'czwp_sqlite_query');
function czwp_sqlite_query($query) {
$query = czwp_sqlite_options($query);
return $query;
}
function czwp_sqlite_options($query) {
$query_lower = strtolower($query);
$detect = 0;
$detect += strpos( $query_lower, 'update' );
$detect += strpos( $query_lower, 'wp_options' );
$detect += strpos( $query_lower, 'null' );
if ($detect >= 3) {
$query = str_ireplace('NULL', "''", $query);
}
return $query;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment