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

[BUG]: Phaclon Model properties conflicts with the database column #14538

Closed
bain2018 opened this issue Nov 16, 2019 · 3 comments
Closed

[BUG]: Phaclon Model properties conflicts with the database column #14538

bain2018 opened this issue Nov 16, 2019 · 3 comments
Labels
bug A bug report status: low Low

Comments

@bain2018
Copy link

create a table user only have three fields id,username,source

CREATE TABLE user (
id int(11) NOT NULL,
username varchar(255) NOT NULL,
source varchar(255) NOT NULL // pls attent this field name *****
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

and pls add a record as the follow
id=1
username=bain
source=conflict

Magic error : // in Chinese:见证奇迹的时刻

$user=User::findFirst([
'conditions'=>'id=1'
]);
var_dump($user->getSource()); // user

$user->username='obama';
$user->save();

catch an error:
Table 'conflict' doesn't exist in database when dumping meta-data for User

if u rename the field source to another name,such as address and flush the modelcache ,if get well

Phalcon version:4.0 rc2
PHP Version: 7.3.11
Operating System: ubuntu

@bain2018 bain2018 changed the title [BUG]: Phaclon Model keywords conflict with the database column [BUG]: Phaclon Model properties conflicts with the database column Nov 16, 2019
@niden
Copy link
Member

niden commented Nov 16, 2019

Only happens if the model does not have public properties defined i.e.

class Sources extends Phalcon\Mvc\Model
{
    public function initialize()
    {
        $this->setSource('sources');
    }
}

If the model is defined like this:

class Sources extends Phalcon\Mvc\Model
{
    public $id;
    public $username;
    public $source;

    public function initialize()
    {
        $this->setSource('sources');
    }
}

the issue does not appear.

niden added a commit that referenced this issue Nov 17, 2019
niden added a commit that referenced this issue Nov 17, 2019
niden added a commit that referenced this issue Nov 17, 2019
niden added a commit that referenced this issue Nov 17, 2019
niden added a commit that referenced this issue Nov 17, 2019
niden added a commit that referenced this issue Nov 17, 2019
@niden
Copy link
Member

niden commented Nov 17, 2019

Resolved in #14542

@niden niden closed this as completed Nov 17, 2019
@niden
Copy link
Member

niden commented Nov 17, 2019

Thank you @bain2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

2 participants