How to store sensitive user data (passwords)
How to store sensitive user data (passwords)
How to store sensitive user data (passwords)
Can’t find out why dbDelta dosen’t create my table
I’ve never had any luck with dbdelta, it has worked spottily at best, and when I code, that’s just not good enough. My method for handling DB changes is to use database versions. So when I create a plugin, I also set the database version, then if I want to update the database, I do … Read more
Found a couple of things and am including what I believe will work to correct your issue. (As an aside, you should try and simplify your initial attempts so you can isolate what works and what doesn’t. This is really complex for an initial attempt.) One thing, you’ll struggle to have a field named timestamp, … Read more
DBDelta is extremely picky— to the point of being maddening sometimes. From the Codex: You must put each field on its own line in your SQL statement. You must have two spaces between the words PRIMARY KEY and the definition of your primary key. You must use the key word KEY rather than its synonym … Read more
Had a similar issue to you. Your problem is the ad_trigger field is a TEXT field. You need to make this a VARCHAR to allow for indexing. TEXT types are not stored in the table. Instead a pointer is stored in the table and the data is stored elsewhere. While you can create an index … Read more
After trial and error, here is the code that works: function installer(){ include(‘installer.php’); } register_activation_hook( __file__, ‘installer’ ); //executes installer php when installing plugin to create new database //database update checkdate function myplugin_update_db_check() { global $xenon_result_db_version; if ( get_option( ‘xenon_result_db_version’ ) != $xenon_result_db_version ) { installer(); } } add_action( ‘plugins_loaded’, ‘myplugin_update_db_check’ ); The installer.php looks … Read more
It appears as though you’re altering the users table – this is a WordPress core table (if using the wp_ prefix) and this is probably not a good idea – create a separate table with an ID foreign key to avoid potential problems. Use $wpdb->prefix to get the prefix that’s actually being used on a … Read more
The reason is due to this code inside dbDelta() : // Create a tablename index for an array ($cqueries) of queries. foreach ( $queries as $qry ) { if ( preg_match( ‘|CREATE TABLE ([^ ]*)|’, $qry, $matches ) ) { $cqueries[ trim( $matches[1], ‘`’ ) ] = $qry; $for_update[ $matches[1] ] = ‘Created table ‘ … Read more
There is error in sql query. You have defined time as datetime and default value mentioned in current_timestamp. Define time as timestamp. Also specify length of email and page fields. Corrected query: $sql = “CREATE TABLE ” . $table_name . ” ( id INT NOT NULL AUTO_INCREMENT, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, //Change datetime … Read more