Okay
  Public Ticket #3332889
Query types supported
Closed

Comments

  • Alexandros started the conversation

    Hello,

    I would like to ask if there is a possibility to run queries like:

    INSERT INTO table_name (field1, field,2, ..., fieldN)

    VALUES (value1, value2, ..., valueN)

    WHERE condition...

    or update queries like: 

    UPDATE table_name

    SET field1 = value1,

    field2 = value,2,

    ...

    fieldN = valueN

    WHERE condition


    Also I notice that  there is no option to execute stored procedures. Is this something that you consider to apply as an option in the future? 

    And if yes how will a stored procedure be triggered (by a button?, a field change?, a record update?...)


    Thank you,

    Alexandros

  •  1,819
    Miloš replied

    Hi, Alexandros.

    Sorry for the delay.

    As some of the points that we mentioned out on this Documentation,

    When working with SQL query based tables, please note:

    1. Our logic is based on a PHP SQL parser which has full support for the SQL dialect for the following statement types:
      SELECT, INSERT, UPDATE, DELETE, REPLACE, RENAME, SHOW, SET, DROP, CREATE INDEX, CREATE TABLE, EXPLAIN and DESCRIBE.
      Some of them like DROP and DELETE, though, are disabled for security reasons.
    2. Using variables ( @ ), stored procedures and nested queries is not supported, but you can prepare a MySQL view (which will return the data you need); call it “view1” for example, and then build a wpDataTable based on a simple query like “SELECT * FROM view1”.

    ( We have a Video example here on how to use a VIEW with JOIN in our Plugin)

       3. For MySQL engine we are dynamically adding the accent grave ( ` ), so there’s no need to use it around the table name in the query.

    - We can use the WHERE conditions in our Queries, i can confirm that.

    -

    But regarding the "INSERT INTO", and the "UPDATE" as from your examples;

     that is not possible at the moment to be directly implemented as part of our SQL Table Queries.

    Our tables will be editable, though, if you enable server-side processing in SQL tables.

    ( * Note about Editing, depending on your Query;  if you use JOINs or a VIEW it won't be Editable.  

    If you need to make foreign key relations between tables and still edit them, you can use our foreign key relation feature.)

    -

    For example, I just tried to run a similar SQL Query as you suggested, like "INSERT INTO table_Name ( fieldName1 , fieldName2 ,...)

    It works in PHPMyAdmin,

    but if i try the same Query in our Plugin, i got this error "INTO not implemented".

    8887894962.png
    6735831432.png

    Basically, it is because our plugin is not a Database Management Tool and is not meant to be used as one.

    Mostly we use it with a "SELECT" command in order to output table columns and data from the Database,  and you can add some functions such as WHERE conditions,

    COUNT, JOINs, etc,  but as mentioned in the important note section,

    our SQL Parser has certain limitations.

    -

    Regarding Stored Procedures, as pointed out in that Note, it is currently not supported,

    but a workaround is to make an SQL VIEW in the Database, then call an SQL Table in our plugin like "SELECT * FROM View_Name".

    We don't plan to add directly using Stored Procedures at the moment,

    but you can make a user suggestion and our management and developers will consider working on that in the future.

    At this time, we don't have a built-in feature to achieve this, but you can suggest it to our developers - they will do their best to make a solution in the future.

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    -

    Also, i wanted to point out that you can test some features on our Demo Sandox before purchasing.

    You can connect the plugin to almost any MySQL, MSSQL, and PostgreSQL database using the Separate DB Connection section in wpDataTables, 

    if you correctly input the details for the connection.

    You first have to check if you have the following drivers installed, and activated.

    3838527468.png

    These drivers need to be installed and activated on the server where your WordPress website is. 

    After you install and activate those drivers, it should work.

    If you're not sure how to install the drivers, please reach out to your hosting provider.

    The server to which wpDataTables is connecting has its own method of establishing the connection, and we're using PHPs logic of connecting to separate connections.

     If there are errors your server returns, those are returned by the server, and only displayed by wpDataTables

     - there's no additional log within wpDataTables that would distinctively show you what's behind the error.

    -

    You can actually test the full features of our plugin, and test your remote DB connection on our Demo sandbox on this link,

    if it is on a live server ( if it is localhost, then It can't be accessed)

    and there is a 15-day money-back guarantee period, So if you purchase the plugin, you can safely fully test it out, and if it doesn't fit your needs you can request and receive a refund in that period. ( same goes for all plugins and add-ons)

    Let me know if you have any questions.smile.png

    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