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

Call to a member function getResult() on boolean #409

Closed
kenan-recebli opened this issue Feb 17, 2017 · 5 comments
Closed

Call to a member function getResult() on boolean #409

kenan-recebli opened this issue Feb 17, 2017 · 5 comments

Comments

@kenan-recebli
Copy link

any find* method of model class throws this error:
screenshot from 2017-02-17 17-42-46

i "played" a little in BASEPATH/Model.php file, and found that dumping $builder->where($this->primaryKey, $id)->get() (for example) works fine, var_dump dumps it as it should, the line $builder->where($this->primaryKey, $id)->get() is assigned to $row variable, but vard_dump($row) dumps false, so the next line $row = $row->getFirstRow($this->tempReturnType) throws an error "Call to a member function getResult() on boolean"

@lonnieezell
Copy link
Member

Hm. Not able to replicate this. Using the latest version of develop, I used the following code in a controller:

$model = new class() extends Model {
	        protected $table = 'job';
        };

	    $results = $model->findAll();

	    $developer = $model->findWhere('name', 'Developer');

	    $politician = $model->find(3);

This is using the database setup from the test data, but all three vars ($results, $developer, and $politician) bring back the correct data successfully. This is using MySQL.

Can you confirm that your database is setup and you can access it through the build directly or with a raw query? Also, what database are you using, Postgre?

I'm a little surprised you're running into this, honestly, since the live database tests on Travis are all coming back successfull. Once we figure out what this is, sounds like we need a better error report of what's actually happening here.

@kenan-recebli
Copy link
Author

kenan-recebli commented Feb 21, 2017

yes, my db is setup and it works as should with ci3, my db is mysql, when i use query builder:

$db = \Config\Database::connect();
$builder = $db->table('table');
$query = $builder->get();

...everything works perfectly, but when i try to using anything from this guide https://bcit-ci.github.io/CodeIgniter4/database/model.html, got the error i described in post

but... i have tried your code example and again got that error on the $politician, the first and second bring back the correct data successfully

@lonnieezell
Copy link
Member

Sorry, I completely dropped the ball on this one.

Did you ever figure out what was going on? If not, can you:

  • verify that the data you're trying to pull from my previous examples does exist in your database with the correct ID (3) for politician, or at least that a row exists there.
  • Show your database config settings

@rudrak23
Copy link

rudrak23 commented May 19, 2022

I had got this issue, fixed now. I had altered table scheme, so column mentioned in select query was not present.

My model code:

$query = $builder->get();
return $query->getResultArray();        //Call to a member function getResult() on boolean on this line

@kenjis
Copy link
Member

kenjis commented May 19, 2022

@rudrak23
We use GitHub issues to track BUGS and to track approved DEVELOPMENT work packages. We use our forum to provide SUPPORT and to discuss FEATURE REQUESTS.

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

4 participants