HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to query custom Table that does not have the GDN_ prefix?


The above code presumes that the table is GDN_custom_table.

Anyone know how to query this without first ensuring that I have the GDN_ prefix?

Thanks in advance.


  • Options
    R_JR_J Ex-Fanboy Munich Admin
    $gdnQuery = Gdn::sql()->select('*')->from('somewhere')->getSelect();
    $query = str_replace('GDN_', '', $gdnQuery);
    $result = Gdn::database()->query($query);

    That only makes sense for complex queries where you want to utilize the query builder. Otherwise you can do a $result = Gdn::database()->query('select * from somewhere'); directly

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    By the way: theoretically you can create a view "GDN_ViewOfExternalTable". That way you can use the external table in the external app without changes and you can additionally use it (for reading access only) with Vanilla.

Sign In or Register to comment.