How to query custom Table that does not have the GDN_ prefix?
Gdn::sql()->select('*')->from('custom_table');
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.
0
Answers
$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');directlyBy 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.