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: Argument 1 passed to CodeIgniter\Database\BaseResult::getFirstRow() must be of the type string, null given, called in /system/Model.php on line 383 #2877

Closed
25hweb opened this issue Apr 24, 2020 · 5 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@25hweb
Copy link

25hweb commented Apr 24, 2020

Hi,
In my model I am trying to get an item by its ID. My code is given bellow:
$id = 5;
$currentUser = new User($id);

I obtain:
Argument 1 passed to CodeIgniter\Database\BaseResult::getFirstRow() must be of the type string, null given, called in /system/Model.php on line 383

CodeIgniter 4.0.2

  • OS: linux
  • Apache 2.4.41
  • PHP Version 7.3.9
@25hweb 25hweb added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 24, 2020
@samsonasik
Copy link
Member

please provide complete reproducible example.

@FelipeAzambuja
Copy link

you send a null on variable $id

@lonnieezell
Copy link
Member

Is User a Model or an Entity?

Either way you have the syntax wrong. If it's a Model, the first parameter would be a database connection. If an Entity, it would require an array of fields, not just an $id var.

Not a bug. Closing. If you need more assistance please ask on the forums.

@abhishekjnvk
Copy link

abhishekjnvk commented Aug 29, 2021

remove __construct() function from Model class.

@rpuig
Copy link

rpuig commented Jul 30, 2024

why do we need to remove the construct from models?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

6 participants