Skip to content

Bug: Builder insert()/update() does not accept an object #6210

@blagi

Description

@blagi

PHP Version

7.4

CodeIgniter4 Version

4.0.4

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

MySQL 5.56

What happened?

Hi, I have a problem with DB Builder
Log:
CRITICAL - 2022-06-30 09:24:34 --> Argument 1 passed to CodeIgniter\Database\BaseBuilder::update() must be of the type array or null, object given, called in ....php on line 41

My mine 40 & line 41:

$builder = $this->dbmail->table(self::TABLE); 
$builder->update($undelivered, ['undelivered_id' => $undelivered->undelivered_id]); 

According to documentation:

$object = new Myclass(); 
$builder->where('id', $id); 
$builder->update($object); 

https://codeigniter4.github.io/CodeIgniter4/database/query_builder.html#builder-update

Builder insert() have a same problem.

Steps to Reproduce

Just do Builder update with object.

Expected Output

No critical or any other error

Anything else?

Looks like the error is in all versions from 4.0.4 until current

Metadata

Metadata

Assignees

Labels

bugVerified issues on the current code behavior or pull requests that will fix themdatabaseIssues or pull requests that affect the database layer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions