We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

sqlite problem

I try make a simple query and I have this:

ERROR: SQLSTATE[HY000]: General error: 1 no such table: /pathtothefile/database.db.users

function: prepare

class: PDO

function: query

class: Phalcon\Db\Adapter\Pdo

function: _executeSelect

class: Phalcon\Mvc\Model\Query

function: execute

class: Phalcon\Mvc\Model\Query

function: find

file: /models/Users.php

so, it is possible to disable databasename prefix in querys ?

I thought that this error is impossible, but it's there

edited Mar '19

Try a setup similar to this:

app.ini (adapt if you're using the array driver)

[database]
connection.host      = 
connection.username  = 
connection.password  = 
connection.dbname    = /path/to/app/cache/data/dev_db

adapter   = Phalcon\Db\Adapter\Pdo\Sqlite
metaCache = Memory
metaCacheOptions.lifetime = 86400
metaCacheOptions.prefix = metaCache
metaCacheOptions.metaDataDir = ../app/cache/metadata/
charset   = "utf8"
prefix = my_table_prefix

DB service:

$di->set('db', function() use ($config, $eventsManager) {
    try {
        $dbConnectionConfig = $config->database->connection->toArray();
        $dbclass = new $config->database->adapter($dbConnectionConfig);
        $dbclass->setEventsManager($eventsManager);

    } catch (\Exception $e) {
        // return a 500 error page would be nicer
        die('db connection failed.');
    }
    return $dbclass;
});

BaseModel:

<?php

class ModelBase extends \Phalcon\Mvc\Model {
    /**
     * 
     * @return string
     */
    public function getSource()
    {
        $name = (!empty($this->getDI()->getConfig()->database->prefix)) ? $this->getDI()->getConfig()->database->prefix . '_' : '';
        return $name . parent::getSource();
    }
}

Users:

class Users extends \BaseModel
{

}

Hope this helps, set prefix in your config to blank if you want to disable. Basically managing the prefix separately instead of passing through to the driver setup.

If not could you post a bit more about your current setup?