Giter Club home page Giter Club logo

Comments (3)

kenjis avatar kenjis commented on June 3, 2024

Cannot reproduce with CI 4.5.1 or 4.4.8.

I see int(5):

    public function testInsertID(): void
    {
        $data = [
            'name'        => 'Apprentice',
            'description' => 'That thing you do.',
        ];

        $this->createModel(JobModel::class);
        $this->model->protect(false)->save($data);

        $lastInsertId = $this->model->getInsertID();
        var_dump($lastInsertId); exit;

        $this->seeInDatabase('job', ['id' => $lastInsertId]);
    }

from codeigniter4.

kenjis avatar kenjis commented on June 3, 2024

The work around we are currently having to use is
to check if we have an primary key id, then calling the insert or update function separately which works fine.

I don't know why the workaround is needed, because it is what the save() method does:

public function save($row): bool
{
if ((array) $row === []) {
return true;
}
if ($this->shouldUpdate($row)) {
$response = $this->update($this->getIdValue($row), $row);
} else {
$response = $this->insert($row, false);
if ($response !== false) {
$response = true;
}
}
return $response;
}

from codeigniter4.

kenjis avatar kenjis commented on June 3, 2024

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.

from codeigniter4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.