I have a Eloquent Builder and two database connections(mysql_server1, mysql_server2) as below: Now how can I change the connection of $builder? Any helps would be appreciated Answer Need to get the Query from Eloquent Builder and set a new connection to that and set the new query to the Eloquent Builder as below:
Tag: query-builder
check if select count value is null/empty query builder symfony
My query builder looks like this is there any way to check that t_total and z_total is null? I don’t want show this row only if t_total AND z_total is null/empty Answer as @mickmackusa say works the way i wanted
Symfony 5 queryBuilder count data
in one of my queries I am joining three tables to allow me to filter by taking into account these three tables. The problem is when I do a counter of the data from the main table (CV table), like I join the language table (ManyToMany), the categories table and the diploma table (manyToMany), when I do a counter of
How to group array by key in PHP Laravel Builder query
I am new Laravel and I just want to group my array by key. Here’s what I have done so far: Code: Return Value: I just want something like this: I tried foreach to $vehicles variable but it says Cannot use object of type stdClass as array is there any way to achieve this? thanks in advance. Have a good
Make A Dynamical Model With Join CodeIgniter
I asked this question yesterday but it got deleted because admins said it got similar question with other post but when I check it there it doesn’t have the same problem with me, so ill ask again and hope that admin can understand. I have this model in CodeIgniter: It has a parameter that I can use dynamically (I mean
Why is this code showing $req variable undefined?
<?php namespace AppHttpControllers; use IlluminateHttpRequest; use IlluminateSupportFacadesDB; class universityController extends Controller { // public function getStudents(…
Adding custom collection to the eloquent within Laravel Query Builder
I have a query and I want to add a collection using Laravel query builder. Well, this returns: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters (SQL: select [{“id”:1,”name”:”John Avenue”},{“id”:4,”name”:”Ontirio Village”},{“id”:2,”name”:”Rovie”},{“id”:3,”name”:”Movie Lot”}] from dogs limit 100 offset 0) I know this may seem like an anti-pattern but the reason I need this is because I have a datatable and
Return values only (no keys/associative array) in Laravel
Situation I have the following code to get all data as an array: This will return the data in the following format: But I want only the values as a regular array (no keys/associative array) so the array is not converted to an object when I convert it to JSON: Inadequate solutions I know I can convert this with a
laravel search multiple words separated by space
I am new to laravel query builder, I want to search multiple words entered in an input field for example if I type “jhon doe” I want to get any column that contains jhon or doe I have seen/tried solutions using php MySQL but can’t able to adapt to query builder how do I do this using query builder this
How to use ‘interval’ in Doctrine2 Query Builder
In my Symfony2 repository, I’d like to get objects from a schedule table, that have started, but not finished yet. The interval, within the objects should be encountered as ‘not finished’, should be passed as a variable. Using plain SQL, it works like this: Can I achieve the same with DQL / Query Builder? This is what I have so