Questions tagged [query-builder]

A query-builder is a set of classes and methods that is able to programmatically build queries.

It provides a set of classes and methods that is able to programmatically build queries, and also provides a fluent API.

This functionality can be embedded on an or be independent.

Functionality

  • Queries more readable
  • Can be cross database

Query Builders documentation

2553 questions
0
votes
0 answers

Laravel query builder whereRaw with convert to datatype returning different results

Here I have two similar queries that return the same result if I paste them directly on SMSS: But when using Laravel's query builder I get different results: //select count(*) from [tbl_rfaccount] where CONVERT(varchar, id) = 'test' $count =…
DanVeira
  • 361
  • 1
  • 6
  • 15
0
votes
1 answer

Access Query sort of Linked tables

I'm using Access 2007. I have two tables, first one has a PK (primary key), but the second has not. When using a query linking the two tables on the PK, I need the rows have the same sort as it is in the second table (means as records has been…
0
votes
0 answers

Laravel querybuilder updateOrInsert method leads to error

I got a curl request that calling external API and i got to save the response from it. I already saved the previous results and now i want to create a cronjob that calls the function everyday to update the data from our api source. But when i…
user12110431
0
votes
1 answer

Laravel - Multiple query function to multiple eager loaded relationships using with method

I'm making a query where the parent model has several relationships. My query returns the correct data when i make only one relationship that o want to filter, the filter works normally. some code before... ->with(['tickets' => function ($query)…
0
votes
1 answer

Rewriting SQL query in Laravel but getting error BadMethodCallException: Call to undefined method

I'm trying to do this query in Laravel. SELECT DISTINCT curriculum.Course_Code, transcript.Course_Grade, transcript.Course_Comp, transcript.CWID FROM curriculum LEFT JOIN transcript ON curriculum.Course_Code = transcript.Course_Code AND…
DelB95
  • 37
  • 5
0
votes
0 answers

How to filter by a relationship attribute when using paginate

I want to implement a search function with latest status of booking. key structure of tables: bookings - id booking_statuses - name (enum: Pending, Done) - booking_id (FK to bookings table) And I have a relationship call 'status_history' I tried…
Fred
  • 11
  • 3
0
votes
1 answer

Why addSelect() in queryBuilder change my query result

I have a query in entity repository with a ManyToMany other entity : Meeting have many Users This is my qb : $userIds = [2]; $qb = $this->createQueryBuilder('m') ->leftJoin('m.users', 'mu') ->leftJoin('mu.user', 'u') ->where('u.id IN…
0
votes
1 answer

How to add comparison in order condition of Yii2 query builder?

So, I have SQL string with order by part like: ORDER BY client_id>0 DESC, date_last DESC I want to have similar condition in Query builder. What i need to add? (especially for "client_id>0") $qr->orderBy([ 'client_id' => SORT_DESC, …
0
votes
2 answers

Laravel 6 Eloquent Query Using WHERE with AND OR AND?

I want to show restaurants which are currently open. How do I say in laravel: WHERE (open = '00:00:00' and close = '00:00:00' ) OR (open < $currentTime and close > $currentTime) I write it like this: ->where(function ($query) { …
0
votes
2 answers

how to run query in codeignitor hook

I want to create hook that check my project is in maintenance mode or not Every thing work fine But db call is not work I try hooks.php $hook['pre_controller'][] = array( 'class' => 'maintenance', 'function' => 'maintenance_check', 'filename' =>…
Partha
  • 81
  • 10
0
votes
3 answers

Invalid interger value (Unable to store value into database)

I would like to ask.I am having trouble where i could not get the id instead I am getting the whole row. public function store(Request $request) { $leave = $request->get('leave'); $leave['user_id'] = Auth::id(); …
Archaana
  • 83
  • 1
  • 2
  • 8
0
votes
1 answer

How to remove an item from a resultset in CakePHP 3?

I'd like to remove some specified items from a ResultSet which means I need a ResultSet object at end. Is there any way to remove an item from a ResultSet or create another ResultSet from existing ResultSet? I've tried using filter() or…
Uske
  • 173
  • 1
  • 1
  • 8
0
votes
1 answer

How to find duplicate values in database with Laravel

How can I find duplicate values in database with Laravel. I want the results like this: name_data - amount (Column name along with amount of duplicate data) I used this code but it didn't work: $duplicates = DB::table('jadwals') …
Gagang
  • 41
  • 1
  • 7
0
votes
1 answer

How to get rid of printing object memory location in output in java project with Query, QueryBuilder and Test classes?

In this java project, I have three classes named Query, QueryBuilder and Test which consists of the main method. Query.java public class Query { private String SELECT; private String FROM; private String WHERE; private String…
0
votes
2 answers

Laravel eloquent save not update field with double value

I have a problem, laravel eloquent not save the updated fields when i call save function there is my example : $user->solde = $user->solde + 2000; $user->save(); the solde field is a double type in database, eloquent not fire event on…
nat
  • 41
  • 1
1 2 3
99
100