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…
Tag: where-clause
Split strings in array to form three-element subarrays
I am practising with the AdventureWorks database for now and I will be receiving strings like the following: SalesOrderNumber=SOH123 and CustomerID=1. The strings may not always contain =, as they may be >, <, >=, <=, !=, <>. Ideally, I would like to split each string into 3 fields – t…
comparing column in database to values in array of objects
i have this array of objects as a result of the following code: it produces something like this : next step, sending this array to model like this: next, filtering like this: i want to filter the rows based on the values in the $varIds array of objects, but this does not work as the where_in clause gives erro…
MySQL SELECT in order of array values
Can anyone help me with a Query query? I have an array of IDs $IDvalues = array(“128”, “159”, “7”, “81”, “82”, “83”); And need to retrieve data from another table in the order of the array. At the moment, I have this query: But it’s…
Search function on multiple rows in the same table
I’m wondering how do I add more row’s on my search script to be searched. Here’s my php script: As you can see this: I want to it to search on region and rank rows. I tried: …. it’s showing 0 results. Thank you in advance. Answer Is this what you want? This searches for the param…
How can I select data from this week using a Unix timestamp in SQL?
I have two columns in my database named dtp_s and dtp_e. Both of these columns hold strtotime() formatted ints which I then use in my PHP application to calculate hours/minutes between time intervals. I want to display the 5 most recent records in date order, which works fine when I use this: However, I now w…
How can I filter one column by two AND conditions?
The question has been resolved. But if you have a “better” or another way to do it then feel free to add a comment! Thanks all for reading! 🙂 I’m trying to make a dynamic query. Everything is …
Laravel where on relationship object
I’m developing a web API with Laravel 5.0 but I’m not sure about a specific query I’m trying to build. My classes are as follows: and Now, I want to get all the events with a specific participant. I tried with: but the where condition is applied on the Event and not on its Participants. The …