Welcome Guest, Not a member yet? Register   Sign In
CI4 Model find returns all rows when key is null
#1

Just checking to see if this is how CI4 is supposed to work. I'm searching in a table for a specific address and the find is returning all rows in the table when the key is null.
Here is the line of code that returns all rows. I'm expecting nothing to be returned.
$address = $this->addressModel->find($venue->address_obj_id);

Here's the model:
<?php

namespace App\Models;

use CodeIgniter\Model;
use App\Entities\Address;

class AddressModel extends Model {
protected $table = 'Address';
protected $primaryKey = 'address_obj_id';

protected $useAutoIncrement = true;

protected $allowedFields = [
'customer_obj_id',
'address_type_obj_id',
'address1',
'address2',
'city',
'state',
'zip',
'default_address'
];

protected $returnType = 'App\Entities\Address';
Reply
#2

Yes, it returns all records.
It's mentioned in the documentation.

If you don't like it, you can offer a PR with changes and justification.
Or rewrite the methods in your own model.
Reply
#3

(03-10-2022, 09:17 AM)iRedds Wrote: Yes, it returns all records.
It's mentioned in the documentation.

If you don't like it, you can offer a PR with changes and justification.
Or rewrite the methods in your own model.
Thank you for the quick response.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB