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

Model setSource #42

Closed
lvphpwb opened this issue Aug 27, 2012 · 12 comments
Closed

Model setSource #42

lvphpwb opened this issue Aug 27, 2012 · 12 comments

Comments

@lvphpwb
Copy link

lvphpwb commented Aug 27, 2012

I use setSource like this

setSource("systemuser"); } } but it don't work, PhalconException: "Table 'siteadmin.users' doesn't exist" when executing "DESCRIBE `users`"
@phalcon
Copy link
Collaborator

phalcon commented Aug 27, 2012

hi, what OS and PHP version are you using?

@lvphpwb
Copy link
Author

lvphpwb commented Aug 27, 2012

centos PHP 5.3.8 (cli)

@lvphpwb
Copy link
Author

lvphpwb commented Aug 27, 2012

Do the model support separation of read and write?

@phalcon
Copy link
Collaborator

phalcon commented Aug 27, 2012

This is odd, 0.4.4 passed that test more than two months ago, check the unit-test and the build log:

https://github.com/phalcon/cphalcon/blob/129b8e70f5639c237c76fdc2076569245a31be98/unit-tests/models/People.php

$people = People::find($params);

http://travis-ci.org/#!/phalcon/cphalcon/builds/1702635

@lvphpwb
Copy link
Author

lvphpwb commented Aug 27, 2012

I can get data from db,but it thow Exception when save data

@phalcon
Copy link
Collaborator

phalcon commented Aug 27, 2012

Anyway to post the code?

@lvphpwb
Copy link
Author

lvphpwb commented Aug 27, 2012

Controller:

username = 'test'; $user->truename = 'test'; $user->usertype = 1; $rs = $user->findFirst(); $user->save(); print_r($rs); exit; } ``` } Model: setSource("systemuser"); } }

@phalcon
Copy link
Collaborator

phalcon commented Aug 27, 2012

Can you write the findFirst as Users::findFirst() ?

@lvphpwb
Copy link
Author

lvphpwb commented Aug 27, 2012

I am sorry, i use Users::findFirst(),but the result is also wrong.

@phalcon
Copy link
Collaborator

phalcon commented Aug 28, 2012

There seems to be a problem with this, Phalcon is calling the method initialize just once, due to this the second model instantiated does not have the new source.

Could you try this:

@lvphpwb
Copy link
Author

lvphpwb commented Aug 28, 2012

yes,it's ok.The framwork is very nice.But i don't know how to use some functions,For example the Db_Pool

@phalcon
Copy link
Collaborator

phalcon commented Aug 28, 2012

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