Skip to content

Tag: sql

how to simplify this complex query

This is an extract of one of my php functions. I’m struggling to get this optimized as is super slow, as I need to load all interview records, and then check if the current user is either assigned as user_id on the interview record, or if the user->id is in the interviews shared_user_ids which is json I’m also using PostgreSQL

Laravel Eloquent where statement returns no attributes

So from my previous post, I was advised to start using Eloquent models, which I did. My end goal, is to print out specific gifts, that belongs to that specific box. Migrations: gift_items: gift_campaigns: Pivot table: Controller: Error that I receive using this way: Seems like the updated version is trying to call the gift_campaigns table id, instead of the

Date range loop into bbdd

I want to make different tables from 2 variables: start date and end date. Example: input start= 05/07/2022 input end= 07/07/2022 so, when I submit the form I want this result: ddbb: id:01 05/07/2022 id:02 06/07/2022 id:03 07/07/2022 I tried this but I got the dates displace, like this: id:01 06/07/2022 id:02 07/07/2022 id:03 08/07/2022 This is the code: Answer

showing contents of a table using PHP in HTML

I have this code snippet: and both inside submit.php, however, while the feedback table inside judges database is not empty, I don’t see any of the rows shown in the HTML page only the column name shows up in the Response tab of Network tab in Firefox Inspect tool. What do you suggest to populate the existing database into the

Resolve name by ID in from 2 tables in PHP / SQL in Datatable

I am currently working on my first datatable which I managed to get to work and I am quite happy with it, however I am having some difficulties in resolving client names. Here is my current code: Tablefile.html: And here my datatable.php file: The table renders fine and works great, however client_id is obviously just outputting their related ID’s, e.g.

retrieve rows based on parent relationship

This is the query: I am trying to get all the checklist items that have the same item_stock_id from the checklists that have the same ambulance_id. However, the query from above is not working, showing me this error: Below is the ChecklistItem model: And this is the Checklist model: Answer To constrain the eager load you need to specify the

How can I print this data in a HTML table with this format?

Imagine that you have this SQL query result: And you want to print a table taking into account the ID_KEY, like this: How can I do that? I want to print a new row when ID_KEY changes. For example, now I have this code: This code won’t work because “value1”, “value2” and “value3”, are fields that do not exist in