prefix() static public method

Adds a prefix to a table name if set in c::set('db.prefix', 'myprefix_'); This makes it possible to use table names in all methods without prefix and it will still be applied automatically.
static public prefix ( string $table ) : string
$table string The name of the table with or without prefix
return string The sanitized table name.
Esempio n. 1
0
}
session_start();
$router = array();
if (file_exists(APP_PATH . 'router.php')) {
    $router = (include APP_PATH . 'router.php');
}
$_uri = router($router);
define('MODULE', $_uri['module']);
define('ACTION', $_uri['action']);
require CORE_PATH . '/db.php';
$db = new db();
if (isset($config['DB_DRIVER'])) {
    $db->set_driver($config['DB_DRIVER']);
}
if (isset($config['DB_PREFIX'])) {
    $db->prefix($config['DB_PREFIX']);
}
$db_host = $config['DB_HOST'] . (isset($config['DB_PORT']) ? ':' . $config['DB_PORT'] : '');
$db->setting($db_host, $config['DB_USER'], $config['DB_PSWD'], $config['DB_NAME']);
$script = APP_PATH . 'action/' . MODULE . 'Action.php';
if (!file_exists($script)) {
    error_404('Can not find the action ' . MODULE . 'Action.php');
} else {
    require $script;
    $class = MODULE . 'Action';
    $method = ACTION;
    if ($method != $class) {
        $run = new $class();
        if (is_callable(array($run, $method))) {
            $run->{$method}();
        } else {
Esempio n. 2
0
 public function testPrefix()
 {
     db::connect(array('database' => self::$database, 'type' => 'sqlite', 'prefix' => 'myprefix_'));
     $this->assertEquals('myprefix_', db::prefix());
     db::connect(array('database' => self::$database, 'type' => 'sqlite'));
 }