I'm trying to create a new plugin to track popular posts based on ideas and I have everything Done and ready to go, but I can not seem to create a new table using the WordPress API (I can do this with standard PHP or phpMyAdmin, but I want this plugin to be self sufficient).
I have tried several ways ($ wpdb-> query, $ wpdb-> get_results, dbDelta), but none of them will create a new table.
function create_table () {global $ wpdb; $ Tablename = $ wpdb- & gt; Prefix 'Populer_b_view'; $ Ppbv_table = $ wpdb- & gt; Get_results ("show tabs like show" "$ tablename." '' ", ARRAY_N); if (is_null ($ ppbv_table)) {$ create_table_sql =" create table "". Fal, Primary ID ('ID'), Unique ('ID'); '' 'Id' BIGINT (50) Faucet AUTACNCRment, 'URL' VARCHAR (255), 'Idea' BIGINT 50) ; $ Wpdb- & gt; Show_errors (); $ Wpdb- & gt; Flush (); If (is_null ($ wpdb- & gt; get_results ("Show table as show". $ Tablename. "'", ARRAY_N))) Echo' nonsense, SQL unsuccessful. '; } Else echo table already exists, nothing has to be done. ';}
instead of the primary key (' id '), SQL There was a problem with the statement, unique ('id')
usage primary key (id), unique (id)
.
Comments
Post a Comment