Coder Social home page Coder Social logo

Update with "where" about php-crud-api HOT 8 CLOSED

focussing avatar focussing commented on June 11, 2024 1
Update with "where"

from php-crud-api.

Comments (8)

focussing avatar focussing commented on June 11, 2024 2

Topper!

from php-crud-api.

mevdschee avatar mevdschee commented on June 11, 2024

Hi Raymond, Thank you for your great question.

If not do you have a suggestion how to deal with this?

Every record should have a synthetic primary key (auto increment or uuid). You can find the primary key using filters. Updates should go on primary keys not on filters.

SELECT id FROM posts WHERE ...
UPDATE posts SET ... WHERE id = ?

I hope you understand this very minimal explanation. Kind regards, Maurits

from php-crud-api.

mevdschee avatar mevdschee commented on June 11, 2024

Hi Raymond,

To answer your specific questions:

Is this possible using the php-crud-api?

No, it is not.

If not do you have a suggestion how to deal with this?

Do multiple http requests.

Kind regards, Maurits

from php-crud-api.

focussing avatar focussing commented on June 11, 2024

Hi Maurits,

Thank you for your suggestions. During the last 2 weeks I have implemented the whole system, and soon it will arrive online.

Reading is easy of course.
The update function needs already to be done via separate api calls one at a time using the already known record id.

Creating and deleting records I did via an "await-loop" which worked fine.
Just this morning I came across the Batch operations, and I already implemented the delete colums-rows-pages already using that very efficient functionality!

One question remains, about creating records in batch. How should I provice the IDs in the url? The IDs are normally not given when creating a record as these are generated in the database itself.
Maybe you can put an example in the docs?

Kind regards,
Raymond

from php-crud-api.

mevdschee avatar mevdschee commented on June 11, 2024

Hi Raymond,

I hope you are aware of the "Batch Operations" section in the manual. You can find various useful examples there including batch creation of records.

see: https://github.com/mevdschee/php-crud-api?tab=readme-ov-file#batch-operations

Batch insert is shown in the tests:

see: https://github.com/mevdschee/php-crud-api/blob/main/tests/functional/001_records/086_add_and_update_posts_in_large_batch.log

Kind regards,

Maurits

from php-crud-api.

focussing avatar focussing commented on June 11, 2024

I am aware, this morning I came across that part in the docs. However I don't see a CREATE batch example...

from php-crud-api.

focussing avatar focussing commented on June 11, 2024

The solution is simple, just post the objects and do not use a key :)
Thanks @mevdschee for this beautiful single file api 👍

from php-crud-api.

mevdschee avatar mevdschee commented on June 11, 2024

Thank you for your kind words. I updated the README to include this information, see: c38083f

from php-crud-api.

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.