Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findOne with dbprefix #52

Open
legionir opened this issue Aug 29, 2023 · 1 comment
Open

findOne with dbprefix #52

legionir opened this issue Aug 29, 2023 · 1 comment

Comments

@legionir
Copy link

legionir commented Aug 29, 2023

Hello,

seems there is a bug with codeigniter "dbprefix" while using findOne and other WHERE methods.
for example:
$this->Products_model->findOne($id)

cause the following error:

Unknown column 'pl_`products.id' in 'where clause'

SELECT * FROM pl_products WHERE pl_``products.id = '1' LIMIT 1

I made a quick fix this change:

protected function _field($columnName)
{
    if ($this->alias)
    {
        return "`{$this->alias}`.`{$columnName}`";
    }

    if (!$this->_db->dbprefix)
    {
        return "`{$this->table}`.`{$columnName}`";
    }

    return "{$this->table}`.`{$columnName}`";
}
@yidas
Copy link
Owner

yidas commented Aug 29, 2023

Hi @legionir ,

You could try the version 2.19.3 to see whether the problem is solved smoothly with dbprefix setting.

Thank you for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants