Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 year ago. Improve this question
Tag: laravel
Laravel binding parameter using insert() with convert() inside
I am having a hard time binding my SQL query and I only have a few braincells left. Basically, this code works but prone to SQL injection: return DB::connection(‘sqlsrv_rfo_user’) ->table(‘dbo….
Binding an unknown number of keywords to a SQL statement with wildcards
I want to bind keywords to a SQL query like this: Note that the number of keywords is NOT predetermined. It is in fact determined by an array which itself is determined by exploding user’s input on space. I am using Laravel 7. So, I am looking for a solution that is consistent with Laravel 7 and PDO. The problem
Laravel Eloquent – Get data from 3 tables with consecutive foreign keys
I’m looking for a way to join 3 Data Tables. Laravel Query; How to fetch data from table ‘c’ by applying a query on table ‘a’? i’m new to Laravel. Answer Basically, it is not as much related to laravel it needs knowledge of the database. You can join 3 tables like this.
Left Join – In Eloquent
I would like to connect user table and like table based on the user_id So I have this Model user.php like.php and my query I would like to return the ‘likes’ table inside the ‘user’ but it doesnt work. I would like to left join it. What am I doing wrong? Answer Well, you need to use one-to-many relation to
Queries in Laravel – Equivalent to left join
Currently this is my laravel query But unfortunately, I would also like to get the connected data between the company and the user table, user_id for company and id for user this is the table company table: and the user table How to I connect the user under the company array? Answer You need to make a relationship for the
Array variable inside DB::raw query laravel
I want to predifine $processingStatus array and use it inside Laravel DB::raw query but this gives me the following error- Syntax error or access violation: 1064 You have an error in your SQL syntax My query is a large one so I am only pasting the fragment which I guess is causing the error- DB::raw(“COUNT(CASE WHEN (status_change_log.status in $processingStatus) THEN
How to always fetch a special category item data first in Laravel
Suppose I have a table named machine with 3 columns(id, name, company). There are 5 data in that table. Here A,B,C,D,E are the machine name and XX,XY,YY are the company name. Now I want to fetch data according to company wise and there a specific company’s data will come always first. For that I use groupBy with company. SQL Result
Laravel Query Builder joining with alias
I have two tables Unknown table Clients table My Code : Joining will be with the clients.id => unknown.parent_id… As because the clients table has a parent_id that’s why i have to use the alias Please Help me to do so! Answer Using Alias Working Solution:
MySQL (Laravel Eloquent) – Get record when two columns have two or more values at the same time
I have this database that I got from this post that manages products and its variants: The problem is, that I don’t know how would I get the SKU at the moment that a user selects the options of the product he wants: Let’s suppose that the user selects the product with ID 1 and the options size-small and color-black,