Okay
  Public Ticket #1709073
Adding columns programatically
Closed

Comments

  • mark fs started the conversation

    Hello again - 

    I'll spare y'all the details as to why, but I need to add columns to a wpdt table programatically. I (more or less) understand the structure. That is, I'll ALTER the table I need to but then I also have to update the wpdt_columns table with those new columns. 

    Is there any documentation on this? What files / classes might I look at so I can mirror the plugin? What I seem to be struggling with is which fields => values required during the INSERT into the _columns table. 

    Also, as a side note, I'm using $wpdb->insert to do the insert. I'm getting a row id from that insert but then the row is not in the DB. So maybe there's something else I'm missing?

    I'm 95% certain this can be done. But it's the key last 5% where I need your help. Please? 

    p.s. I would be nice if you have a debug mode or something. Sometimes I get detailed errors, other times I do not. 

  •  1,708
    Miloš replied

    HI mark fs,
    Thank you for your purchase.

    You can take a look at our topic from documentation for developers to see all of the available hooks and filters that you can use in our plugin.

    Hooks

    Filters

    Hope this can help you out.


    Best regards.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • mark fs replied

    Hi Bogdan - 

    Thanks. Yes. I saw those, of course.

    The hooks are a When. I'm more interested in a What. That is a page that discusses using $wpdb to add cols and data**.

    The filters might have helped but they weren't very clear. A couple example would help, as would examples of the data objects / arrays that get passed in. I'm new to your product so some variable name doesn't do me much good. 

    In the end, I add a column manually, looked at what happened in the DB and then made my code produce the same results. This was the most time 

    ** for anyone else who might be curious, datatable.js does __not__ like it when the (column) pos is not sequential. For example, as a quick do, as I was working through other details, I was using a pos = 100 (for a column I was adding via code) in a table with 20-ish col. "Just stuff it at the end" I figured. Well, dt.js threw a warming when I went from pos = 20 to pos = 100. Evidently the pos MUST be sequential.