Welcome Guest, Not a member yet? Register   Sign In
Best way to use db table prefix
#1

So I include $db = ... in every functions
and in each RAW $sql, I use $db->prefixTable('table_name')

It works but is this the ideal way of coding it in CI4?

PHP Code:
function get_include_files()
{
    $db = \Config\Database::connect();

    $include_files = array(); // must return something

    $sql "SELECT plugin_id, plugin_includes FROM " $db->prefixTable('plugins') . " WHERE plugin_enabled = 1";
    ... 

Thanks.
Reply


Messages In This Thread
Best way to use db table prefix - by bustersg - 09-17-2019, 08:52 AM
RE: Best way to use db table prefix - by MGatner - 09-18-2019, 04:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB