Questions tagged [dbdelta]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
19 views

Can't find out why dbDelta dosen't create my table

I have a function which needs to create a new table an d i can't see for the life of me why it dosen't create the table: function afdv_create_delivery_table ( $id ){ global $wpdb; $...
user avatar
0 votes
1 answer
15 views

Why my query 'REPLACE INTO...' does not work?

To insert or update data if data exists, I was using 'REPLACE INTO...' in a var $query_string like this : dbDelta( $query_string ); For some reason, the row is not insert. Why ?
user avatar
  • 770
0 votes
0 answers
140 views

How to store sensitive user data (passwords)

I want to create a plugin addon that allows my sites users to share private login information in a secure manner. So they'll enter these private details in a form on the frontend and I want to be able ...
user avatar
  • 135
0 votes
1 answer
884 views

CREATE TABLE with dbDelta does not create table

I based this code from the codex on the docs. I placed it in my main plugin file but it's not creating the database table. Have I missed something? // Database setup and hooks function ...
user avatar
  • 13
1 vote
1 answer
73 views

Adding a Table to the wordpress database

I am using the following script to add a table to the wordpress database, but nothing is happening. I am not sure what I am doing wrong. Any advice would be much appreciated. function ...
user avatar
0 votes
2 answers
165 views

cant insert data in a custom table in phpmyadmin

i created a dbdelta table but i cant seem to insert any data here is my code please help function lapizzeria_save_reservation() { global $wpdb; if(isset($_POST['reservation']) && $_POST['...
user avatar
0 votes
1 answer
139 views

dbDelta not CREATING TABLE

Here's my code. Please help function lapizzeria_database() { global $wpdb; global $lapizzeria_db_version; $lapizzeria_db_version = "1.0"; $table = $wpdb->prefix . 'reservation'; ...
user avatar
1 vote
1 answer
64 views

dbDelta with the character ;

To manage database plugin update, I changed my code using dbDelta. old code myfunction(){ ... $query_string = "INSERT INTO {$table_name} {$str_column_names} VALUES {$str_values}"; $...
user avatar
  • 770
0 votes
1 answer
346 views

Create table with dbDelta,can't put any DEFAULT data

I want to add more custom tables to wp_users. but I want them to contain a default JSON data. This one works...when the DEFAULT is empty... register_activation_hook(__FILE__, 'toto_user_db_setup')...
user avatar
  • 13
0 votes
1 answer
81 views

Creating a database in my plugin not working

Good day everyone, I've been trying to add a table in my database for a whole day now, and I can't seem to find the error, I looked into multiple similar questions, but I had my syntax similar to all ...
user avatar
1 vote
1 answer
493 views

Plugin: register_deactivation_hook works perfectly well, while register_activation_hook suddenly stopped working

So interestingly, I moved my main plugin file into a folder within the plugin directory. Where before the register_activation_hook worked perfectly well, it now does not work; however, the ...
user avatar
1 vote
1 answer
114 views

The function can not create a table on MariaDB server

The function works on MySQL server well but it can not create a table on the MariaDB server. What could be the problem? public function create_table() { $current_version = get_option('...
user avatar
1 vote
0 answers
283 views

dbDelta not creating table (yes, once more)

I KNOW there are other posts relating to my issue, i read all of them and tried to see if the answer would change and tried a few ones, but I can't seem to create my table using it. Here's my code (...
user avatar
  • 31
2 votes
2 answers
3k views

Custom database table for plugin not creating on activation

Let me start by saying I know there are other posts about this, and a lot of documentation is available for this topic, but none of these resources have helped me to solve my issue. I'm a beginner at ...
user avatar
0 votes
1 answer
943 views

dbDelta not adding additional columns in plugin database update

I'm trying to update my database by adding an extra column field. However, dBdelta does not seem to be doing its job. I'm not sure what am I doing wrong. <?php function installer(){ include('...
user avatar
1 vote
2 answers
2k views

Unable to create new database table upon plugin activation using dbDelta

I'm trying to create a new database table when my plugin is activated using dbDelta() however, no new table seems to be creating. Since I'm new to WordPress development, please let me know where I'm ...
user avatar
3 votes
1 answer
6k views

Fatal error: Call to undefined function dbDelta()

I want to create a table during the activation of the plugin, so I used the code as follows: class Database { private $db_version = '1.0', $table_prefix; public function __construct() { ...
user avatar
  • 205
4 votes
1 answer
941 views

dbDelta does not create Table, but returns success

I wrote a Plugin, which creates a table on activation. On previous WP Versions, it worked fine. Now it doesn't. This is my function: function on_activation(){ global $wpdb; $...
user avatar
1 vote
1 answer
671 views

dbDelta() Error - Incorrect index name '' for query ALTER TABLE

The famous dbDelta() function in WordPress is causing me problems in multiple plugins. No change I make to my create table query seems to fix the problem or it does fix it and dbDelta() causes a ...
user avatar
1 vote
2 answers
2k views

How to update an existing table while updating plugin?

I have added a new field (time_last_seen) in my plugin (v1.1) table then uploaded my plugin as version 1.2 to wordpress svn repository. When I update my plugin from admin panel, it is not creating ...
user avatar
0 votes
1 answer
1k views

DBDelta: "table doesn't exist" for a table that was just created

When I run the following code: global $wpdb; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $table_tags = $wpdb->prefix . "tags_tb"; $sql = "CREATE TABLE $table_tags ( ...
user avatar
  • 103
6 votes
1 answer
1k views

How to define composite keys with dbDelta()

I am getting error while trying to create a table with dbDelta() and composite primary key. The sql is pretty straight forward. $sql = "CREATE TABLE {$wpdb->prefix}voicemail_call ( user_id ...
user avatar
  • 7,615
1 vote
1 answer
117 views

Unable to set a default serialized array using dbdelta()

I am trying to set up a table with dbDelta() and one of the columns will have as default a serialized array with predefined values. The issue here is that dbDelta() explodes the query using ...
user avatar
0 votes
1 answer
363 views

dbDelta not installing database

I'm not sure why this isn't running. When I output dbDelta it says that it created the table, but it doesn't. I think my SQL is valid. Taking everything out between id and UNIQUE KEY results in the ...
user avatar
  • 1
0 votes
1 answer
2k views

dbDelta not creating tables with composite keys

I've been trying to figure this one out for 3 days now, reading every reference on dbDelta I can find. My ultimate goal is to create a table of unique ad_id, ad_trigger pairs. This does not create a ...
user avatar
0 votes
1 answer
54 views

Creates only one table and not the other

I have this function to create two tables when I activate the plugin. Only the wp_wpt_stats table are being created and not the wp_wpt_list. I know the dbdelta is picky, but I can't see what I'm doing ...
user avatar
0 votes
1 answer
69 views

Wordpress dbdelta a semicolon

I have a query, something like this $drzava ="CREATE TABLE IF NOT EXISTS`wp_drzava` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Kod` varchar(2) NOT NULL, `Naziv` varchar(100) NOT NULL, ...
user avatar
3 votes
2 answers
2k views

Why does dbDelta() not catch MysqlErrors?

From what I can see, dbDelta() is designed to suppress database errors that occur during its operation. Generally speaking, this seems to be the case, but New Relic is still reporting MysqlErrors ...
user avatar
  • 1,381
-1 votes
1 answer
229 views

What is wrong with this dbDelta syntax?

I know there's a million questions about this, but I've searched a bunch and haven't found any solutions that fix my problem. This is the function which I hook upon plugin activation: global $wpdb; $...
user avatar
0 votes
1 answer
125 views

Create new database through static page code

I want to create a new table in current database of word press through create a static page. I write code for this as below, but there was no result. Why is that, and how can I get this right? <?...
user avatar
  • 1
0 votes
1 answer
267 views

Is altering a default WordPress database table update safe?

I want to add some table columns to the wp_terms table. Is it safe to use the dbDelta function with a modified CREATE-MySQL query for this? Or will I run into problems in the long turn? Is it update ...
user avatar
  • 4,305
1 vote
1 answer
1k views

dbDelta using Foreign key not working on update [duplicate]

I am using FOREIGN KEY with dbDelta when activating the plugin (register_activation_hook()). It works great when creating the table for the first time, but outputs an error when updating the table (...
user avatar
0 votes
1 answer
81 views

dbDelta not doing what it says

Okay so I must have read hundreds of wordpress answers, google results etc on different people having trouble with dbDelta creating tables for their plugins. Ive tried many variations based off of ...
user avatar
  • 101
0 votes
1 answer
172 views

Print output of Table Creation

I am creating a few tables and I getting the following message: The plugin generated 440 characters of unexpected output during activation. If you notice “headers already sent” messages, problems ...
user avatar
  • 545
2 votes
2 answers
112 views

What files to keep after upgrading WordPress?

We were recently handed a few blogs/sites to support, that have started way back when wordpress was on v2.1.3 or even 2.0.4 After upgrading the sites to the latest versions (3.4.2 and 3.5) we found ...
user avatar
3 votes
2 answers
13k views

dbDelta ALTER TABLE syntax?

Due to some changes in the DB, I need to alter a table to add one column to it, but even though the function is running, the table isn't altered. Here's the ALTER TABLE code that I've written $sql = "...
user avatar
  • 445
15 votes
5 answers
15k views

dbDelta not creating tables

I went through a lot of threads, codex page and tried messing with a lot of things but my code doesn't seem to be creating the tables. And I am not able to figure out where I am going wrong. I checked ...
user avatar
  • 445
10 votes
2 answers
4k views

Does dbDelta delete columns as well?

I created a table using the dbDelta function and then removed a few columns and added a few. The new columns did get created but the old columns did not get deleted from the table. Is there a ...
user avatar
2 votes
1 answer
1k views

Problem in creating table through plugin code

I'm using the following code to create the database table using plugin. However, the table is neither getting created nor I'm getting any error message. The code is as follows: global $wpdb; ...
user avatar
  • 191
10 votes
1 answer
4k views

dbDelta support for FOREIGN KEY

On PHP 5.3.13/MySQL 5.5.21 the following code doesn't work: if($check_custom_fields_form!=1){ $sql = "CREATE TABLE IF NOT EXISTS ". $table_custom_fields_form ." ( `form_name` ...
user avatar
  • 564
8 votes
2 answers
4k views

dbDelta only creates the last table

I'm using following install function with dbDelta as referring to the codex, articles on SO I watched out for the typical problems with e.g. one space instead of two spaced at the PRIMARY KEY ... ...
user avatar
  • 351
0 votes
1 answer
1k views

dbdelta failing with error: "WordPress database error Table 'wp_2_myPlugin' already exists

I'm upgrading a plugin and having issues with dbdelta. Here's the original db creation function: global $jal_db_version; $jal_db_version = "0.1"; function jal_install() { global $jal_db_version;...
user avatar
4 votes
1 answer
2k views

Problems with DBDelta with FOREIGN key?

I have the following sql I am using with dbDelta: $sql .= "CREATE TABLE " . $location_table . " ( location_id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, name VARCHAR (100), ...
user avatar