Skip to content

findOne with dbprefix #52

Description

@legionir

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}`";
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions