I have 2 tables reserves and chats, chats belongTo reserves and I want to get all chats where chat.reserve.user_id = Auth::id(). How can I do that in laravel. Answer I don`t know your models name (need more code in question), but try use where ‘reserves’ your relationship and have field user_id. Maybe needed full path to field like ‘reserves’.’user_id’ Also
Tag: sql
My SQL request work in SQL but not in PHP
I’m trying to make an unique request to insert multiple element in my database to not make multiple request. Here is my “generated” request, which work in SQL (tested in PHPMYADMIN). Generated by this code. But I get this error in PHP Do you know why this request does not work when I try to use it with PHP ?
How do you fetch data from the database? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question I created a row in my database named “temperature” and wanted to include it in a table on the webpage I have created but I don’t
PHP odbc_exec not returning all rows
This simple query when run in DBExplorer (a DB tool for executing raw SQL queries), returns 5 rows (contents of an invoice). Everything is setup in such a way that an invoice may contain multiple goods of the same ID (but with different prices and procurement prices, printing names – e.g. bucket-white, bucket-blue, bucket-red, etc). Each of the items gets
How to get data after @ in SQL
I have a table in the database that looks like this id email 1 user@domain.com 2 user@domain2.com 3 user@domain3.com I have a form that looks like this In the backend I’m trying to match the input email domain with the ones in the database, after “@”. What I’ve tried (if user enters: test@domain2.com) How should I add a Query that
User’s cant upload images on published website
I have a website which you can upload pictures and see them. I was uploading and gettin pictures with no problem on localhost but after publishing with freewebhostingarea i get these errors. Warning: move_uploaded_file(img/pexels-garvin-st-villier-3874337.jpg): failed to open stream: Permission denied in /home/vhosts/jdm-sepeti.eu5.org/addCarF.php on line 22 Warning: move_uploaded_file(): Unable to move ‘/tmp/phpHdU7FE’ to ‘img/pexels-garvin-st-villier-3874337.jpg’ in /home/vhosts/jdm-sepeti.eu5.org/addCarF.php on line 22 This is
Insert a value at a NOT NULL column int in SQL Laravel Eloquent
I need to have this eloquent inserting data into my table with my first two columns, id, category_id be added with auto increment, specifically, the highest value + 1. my code above has the error: what can I at the “max()” for this to function as intended? any help would be appreciated thanks. Answer you have error in I think
How to join data table to select newest record in sql
I have two separate table LPG_usage and devices. In the LPG_usage table has 5 columns as (Device_id,Cylinder_Type,Date,Kg,Data_index ) and the devices table has 3 columns as (Device_id,User_name,Location) I want to select newest record by considering the Date in the LPG_usage table for all of Device_id’s with the Location at the device table. The selected table include (Device_id,Cylinder_Type,Date,Kg,Location) I made a
How to check if SQLite row is empty
I have the following which only inserts to column two if the value is empty: However, this only works if column two if the value is null. How can I get this to work if it is either NULL OR an empty string. It should always insert to one and three. It should only insert to two if it is
Update SQLite row only if a column is empty
I have the following: one and three should always be updated. However, how can I update two only if it is null/empty? I can do this in a separate command, though how can I achieve this in one prepared statement? I am using SQLite3 Answer Use a CASE expression for column two: Or with COALESCE():