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] Phalcon\Mvc\Model\Row does not fully implement Phalcon\Mvc\Model\ResultsetInterface #1506

Closed
thewalkingtoast opened this issue Nov 2, 2013 · 3 comments

Comments

@thewalkingtoast
Copy link

These work just fine:

// works
$user = User::find()->toArray();

echo json_encode($user);

// works
$user = User::findFirst()->toArray();

echo json_encode($user); 

However, adding conditions breaks Model::findFirst():

// works
$user = User::find([
     'columns'    => 'id,company_name,email',
     'conditions' => 'id = ?1',
     'bind'       => array(1 => '1')
])->toArray();

echo json_encode($user); 

// Fatal error: Call to undefined method
// Phalcon\Mvc\Model\Row::toArray()
$user = User::findFirst([
     'columns'    => 'id,company_name,email',
     'conditions' => 'id = ?1',
     'bind'       => array(1 => '1')
])->toArray();

echo json_encode($user); 
@thewalkingtoast
Copy link
Author

My thought is that

echo json_encode(User::findFirst()->toArray()); // works
echo json_encode(User::findFirst($conditions_array)->toArray()); // doesn't work

feels inconsistent even though in the first example, the toArray() is unnecessary.

phalcon pushed a commit that referenced this issue Nov 25, 2013
Fix #1506 in v1.2.5 add Model\Row::toArray
@ghost
Copy link

ghost commented Nov 26, 2013

But did Phalcon\Mvc\Model\Row mean to implement Phalcon\Mvc\Model\ResultsetInterface?

As far as I can see, this class implements only two interfaces: ArrayAccess and Phalcon\Mvc\Model\ResultInterface, it does not have any necessary methods to implement ResultsetInterface.

@phalcon what do you think?

phalcon pushed a commit that referenced this issue Nov 27, 2013
@phalcon
Copy link
Collaborator

phalcon commented Dec 19, 2013

Implemented in #1604

@phalcon phalcon closed this as completed Dec 19, 2013
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

1 participant