• Resolved jhione

    (@jhione)


    Hello Peter,

    I created a new blank HTML page purely for testing purposes and keeping it simple.

    I have a view that I have used successfully as a Data Publication WP Data Access Premium. I wanted to custom style the results so installed Code Manager after I saw some response and code in the WPDA support forum. I tried that code first without success.

    $wpdadb = WPDADB::get_db_connection( ‘rdb:my_db’ );
    $rows = $wpdadb->get_results( ‘select * from my_view‘, ARRAY_A);

    The code example mentioned above is a little different from the example in the PHP code library example, but I figured I would try the library code next…

    <?php
    $wpdadb = WPDataAccess\Connection\WPDADB::get_db_connection( ‘rdb:my_db’ );
    $rows = $wpdadb->get_results( ‘select * from my_view‘ );
    
    var_dump($rows);
    ?>

    This did not return results either. Steps I have taken:
    1) Verified names of db and view (several times)
    2) Checked settings in both WPDA and CM (several times)
    3) Tested ‘Hello World’ PHP shortcode successfully to verify shortcodes and CM are working

    Is there something obviously incorrect in what I have above? If not, do you have an example of code I could put in to confirm that the connection was made, or can you suggest a next step in debugging this? Thank you and very much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @jhione,

    Your code is correct. It works for me. I just needed to change the quote like this:

    <?php
    $wpdadb = WPDataAccess\Connection\WPDADB::get_db_connection( 'rdb:my_db' );
    $rows = $wpdadb->get_results( 'select * from my_view' );
    
    var_dump($rows);
    ?>

    When you exchange text between a webpage and an editor, quotes and doubles quotes are often changed. ?? Does this solve the issue?

    Best regards,
    Peter

    Thread Starter jhione

    (@jhione)

    Hi Peter,

    Thank you, yes that worked. Really appreciate your help.

    • This reply was modified 3 years, 2 months ago by jhione.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remote db and results’ is closed to new replies.