Questions tagged [dbdelta]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
0 answers
44 views

Creating a table via dbDelta

I'm trying to figure out exactly how to create table structures in databases correctly, and after doing my research I'm left with a couple of questions that I can't find an answer to: In MySQL, there ...
doesnot's user avatar
  • 21
0 votes
1 answer
18 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 ?
J.BizMai's user avatar
  • 820
0 votes
0 answers
228 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 ...
dylzee's user avatar
  • 135
0 votes
1 answer
2k 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 ...
FCD's user avatar
  • 13
1 vote
1 answer
204 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 ...
Victoria Whitehead's user avatar
0 votes
2 answers
213 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['...
Arvin Bahilango's user avatar
0 votes
1 answer
225 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'; ...
Arvin Bahilango's user avatar
1 vote
1 answer
73 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}"; $...
J.BizMai's user avatar
  • 820
0 votes
1 answer
554 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')...
Kefka's user avatar
  • 13
0 votes
1 answer
98 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 ...
BeedZ Sh.'s user avatar
1 vote
1 answer
589 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 ...
Chad Denaux's user avatar
1 vote
1 answer
137 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('...
Andrew B.'s user avatar
1 vote
0 answers
287 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 (...
Chuck's user avatar
  • 31
2 votes
2 answers
4k 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 ...
Rich Bannon's user avatar
0 votes
1 answer
1k 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('...
Himanshu's 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 ...
Himanshu's 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() { ...
Stranger's user avatar
  • 205
4 votes
1 answer
1k 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; $...
user998163's user avatar
1 vote
1 answer
885 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 ...
Ryan Bayne's user avatar
1 vote
2 answers
3k 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 ...
Faiyaz Alam's 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 ( ...
ig343's 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 ...
Sisir's user avatar
  • 7,772
1 vote
1 answer
135 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 ...
Jorge Rivera's user avatar
0 votes
1 answer
421 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 ...
DCo's 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 ...
FeralReason's user avatar
0 votes
1 answer
61 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 ...
Roger Andersen's user avatar
0 votes
1 answer
76 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, ...
Vladimir Štus's user avatar
3 votes
2 answers
3k 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 ...
rinogo's user avatar
  • 1,431
-1 votes
1 answer
255 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; $...
Justin Folvarcik's user avatar
0 votes
1 answer
126 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? <?...
vani's user avatar
  • 1
0 votes
1 answer
288 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 ...
Roman's user avatar
  • 4,475
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 (...
CodePorter's user avatar
0 votes
1 answer
88 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 ...
mihok's user avatar
  • 101
0 votes
1 answer
218 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 ...
William's user avatar
  • 545
2 votes
2 answers
113 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 ...
marikamitsos's user avatar
5 votes
2 answers
15k 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 = "...
mehulved's user avatar
  • 475
15 votes
5 answers
17k 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 ...
mehulved's user avatar
  • 475
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 ...
Prakash Raman's 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; ...
Pooja's user avatar
  • 191
11 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` ...
Gaia's user avatar
  • 584
8 votes
2 answers
5k 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 ... ...
mybecks's 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;...
rpophessagr's 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), ...
redconservatory's user avatar