Questions tagged [query-builder]
A query-builder is a set of classes and methods that is able to programmatically build queries.
2,459
questions
0
votes
0
answers
10
views
How to include a list view in the details show view sonata bundle
I'm trying to have a query result in the show view and then to normally edit/delete the rows as in the list view (pagination as well).
As far I did this:
protected function configureShowFields(...
0
votes
1
answer
25
views
i want to get only 3 blog of per category. but code return me all blogs of per category laravel
i want to get only 3 blog of per category. but code return me all blogs of per category laravel
example i have 2 category (category 1 haves 10 blogs and category 2 haves 7 blog). now i want only 3 ...
0
votes
0
answers
20
views
Transformation of fairly complex SQL query into TypeORM Query Builder statement
as someone with not too much of typeORM experience I recieved the task of converting my fairly complex SQL query into a typeORM query builder statement.
We are using a postgres DB.
Here are my ...
0
votes
0
answers
7
views
How do i build this select month query using TypeORM's QueryBuilder?
I ran this code directly on MySQL server and I'm getting the desired results, now how do I replicate this in my code using typeORM's queryBuilder?
> SELECT MONTH (fecha) month FROM ventas GROUP ...
-1
votes
2
answers
41
views
How to get records with multiple where in many to many relationship?
I'm working on a Laravel version 9 project. At first, I explain the tables and relationships.
There are 3 tables:
advertisements, advertisement_tags and the pivot table advertisement_advertisement_tag....
0
votes
1
answer
28
views
After common Typeorm query builder instance, where clause not working
I create QueryBuilder to fetch my relation data. So in my case, I need to validate some of my
get req params before the index. So in this case I created a common QueryBuilder instance like this.
// ...
0
votes
2
answers
30
views
Do not retrieve all columns with Elastic search query
I have an Elastic search query and I would like to retrieve a certain column, not all.
I make my request in java with BoolQUEryBuilder which gives:
BoolQueryBuilder query = boolQuery();
query.must(...
0
votes
1
answer
43
views
Doctrine QueryBuilder - add PARTITION selection in clause FROM
I have a table "actions" with partitions
PARTITION BY RANGE (MONTH(`created_at`)) (
PARTITION `m1` VALUES LESS THAN (2),
PARTITION `m2` VALUES LESS THAN (3),
...
0
votes
1
answer
44
views
Use parameter with DB::raw in Laravel 9
I have this SQL query which returns all employees based on selected date :
SELECT employees.id as employee_id ,employees_salaries.*,CONCAT(first_name,' ',second_name,' ',third_name) as fullname FROM ...
0
votes
3
answers
66
views
How to change Eloquent Builder's connection?
I have a Eloquent Builder and two database connections(mysql_server1, mysql_server2) as below:
$builder = User::query();
$builder->where('age', '>', 20);
$builder->with('orders');
// ...
0
votes
1
answer
21
views
How to write this SQL query with Yii Query Builder
I have this SQL query which is doing what I want:
SELECT `Table1`.* FROM `Table1`
LEFT JOIN `Table2` ON `Table1`.`idTable2` = `Table2`.`id`
WHERE (`Table1`.`idOwner`=156 AND `Table2`.`enabled`=1 AND ...
0
votes
1
answer
52
views
unable to select alias in getMany Typeorm
I'm using TypeORM(mySQL) for my Nestjs App. I want to change the column name on select using querybuilder. but it's not working.
const order = await this.connection
.createQueryBuilder(Orders,&...
0
votes
0
answers
25
views
Laravel query builder not delete the data but when convert into raw query it works [duplicate]
Here is my code i just want to remove duplicate rows but it not execute
DB::table('competition_participants as t1')
->join('competition_participants as t2', 't1.id', '<', 't2.id')
->...
-1
votes
1
answer
49
views
Laravel Paginate by column value
I would like to find out if the following is possible with laravel query builder. Currently using Laravel 9.
I want to create pagination, but instead if supplying the count
->paginate(20) as per ...
0
votes
1
answer
38
views
i want to get all user data with data on behalf of batch_id
i want to get data in instructor dashboard on the behalf of batches assigned to them from order product table where if user buy single course then we get batch id and if user buy package(package ...
0
votes
0
answers
39
views
Angular-QueryBuilder- custom operators
Is it possible to create custom operators on Angular-QueryBuilder?
I saw it is possible on https://querybuilder.js.org/#operators, but I'm trying to use Angular-QueryBuilder.
I tried this:
config: ...
0
votes
1
answer
42
views
Access level to Illuminate\Database\Query\JoinClause::forSubQuery() must be public laravel error?
I have a simple decent query in my laravel application which is nothing but a left join
$spDetails = ServiceProvider::from(‘ipay_app.service_providers as sp’)
->leftJoin(‘ipay_app_bbps....
0
votes
0
answers
22
views
knex transactions in the same network request (no dependencies)
When writing transactions in application code you have 2 situations:
A: You need to grab some data from the database, modify it in the app code, then do a subsequent SQL update using that modified ...
2
votes
0
answers
99
views
Sorts on relationships with Spaties QueryBuilder
Having the following QueryBuilder statement how can I define sorts on related models columns?
$members = QueryBuilder::for(Member::class)
->allowedIncludes('user.name', 'association', '...
0
votes
1
answer
24
views
Codeigniter 4 - Getting result from database issue
I'm new to codeigniter 4 and having some issues retrieving data from my database.
In my controller, I have:
$partno = model(Ecart_model::class)->getPartno($productid);
echo json_encode($...
0
votes
1
answer
26
views
Laravel only join linked model if parent has boolean switch
I'm using Laravel 8 and have two models: Domain and Certificate. A domain can have one certificate.
On my domain model, I have a boolean column called certificate_checks_enabled, and where I'm ...
0
votes
0
answers
17
views
C# (sqlkata) - Error in mapping model fields to DB fields
I'm trying insert data to database table using sqlkata insert query builder.
Whenever I run code i get 'Invalid column column name' error. Note that I'm using data annotations to map model fields to ...
0
votes
1
answer
31
views
Laravel Query Builder How to Context Not Conditions
I have a laravel query
PasswordMovement::whereId($id)->update(['active' => '!active']);
my active field converts to 0 if it is 1. but if it is 0, it doesn't convert to 1?
Laravel Query Builder ...
0
votes
2
answers
68
views
Laravel how to addSelect all total counts on a single table each row
i am trying to build a single query but something is wrong. i want to write a code that each row have a all total count on a one table. i will describe
first i will query the total counts :
$count = ...
2
votes
0
answers
36
views
How Can I compare table column by convert it first in postgresql + typeorm
I am beginner in Backend technology and I am developing one query in Typeorm QueryBuilder + PostgreSQL.
My query is look like this :
But I can't convert my timestamp into following format. Can anyone ...
0
votes
1
answer
23
views
how to include with no count rating star row in laravel query builder
so here is my problem
i want to include rating 2 and 3 with their rating count 0, but i don't have idea how to query builder that. and i don't know if is possible to do that thing.
like this example ( ...
0
votes
1
answer
39
views
Each letter typed in input is causing rerendering component in React Querybuilder
I'm using react query builder with MaterialUI and I found a bug in ValueEditor where each typed letter in TextField is causing rerendering.
Here is codesanbox example of same thing using regular input ...
0
votes
0
answers
42
views
Problem optimization with symfony/doctrine : too many querys
The project is develop with symfony 6.0.8.
I have 2 entitys : utilisateur (user) & compte_client (customer) - link by OneToOne relation because an user may be not a customer. A user can be : an ...
-1
votes
2
answers
64
views
Return ORM object and convert SQL to Doctrine QueryBuilder syntax
I'm creating a function that should return an array of User ORM object. The function should run a query to the DB and return the users where the users' contact persons has 1 company (not more or less)....
0
votes
1
answer
80
views
how to get last query in codeigniter 4?
This is my current code:
public function index()
{
$tbl = 'm_trx';
$db = \Config\Database::connect();
$builder = $db->table($tbl);
$data = [];
$cols = "{$tbl}.*";...
0
votes
1
answer
20
views
Filter in formbuilder with querybuilder (Symfony)
p is profile and u is user. Each user has one or more profiles. I want to filter one profile from each user who have more than 10 points. But I want to keep only one profile of each user that meets ...
2
votes
1
answer
36
views
is there a tool or any quick way to extract db tables automatically from my php codes?
I recently started to re-engineer a PHP-mysql project which was created about 7 years ago. I have only php and html codes and no mysql database or any document which shows the database structures.
Is ...
0
votes
2
answers
114
views
Laravel: Which one is better to "reset" a table: ->truncate() or ->delete()?
I'm using ->truncate() to delete the data, but DB::rollback() in a try catch doesn't executed when I use it. Meanwhile the ->delete() is executed by DB::rollback(), but with it my auto increment ...
0
votes
1
answer
51
views
Order multiple entities by date with query-builder (Symfony)
I was wondering if I could possibly order multiple entities by their date of creation with the query builder in Symfony.
This is my query:
public function findContributions(Association $association)
...
0
votes
0
answers
27
views
Can't figure out how to execute complicated query in SQL with query builder from Laravel
Hello I am working with October CMS and In trying to filter my records in the function
listExtendQuery($query){$query->where([['statusi','=','Perfunduar'],['miratim_niveli1','=',null]])->orWhere(...
1
vote
1
answer
34
views
How to compare Query conditions from a BelongsToMany association in CakePHP 4.x?
I have a working Posts, Categories and Tags relationship. (Posts BelongsTo Categories and BelongsToMany Tags.) They work just fine at my view and index actions with no issue.
Now, for a simple "...
2
votes
1
answer
121
views
Laravel Query builder where() for when Product has to have multiple tags (with product_tags pivot table many-to-many)
I am new to Laravel and I got a complicated query to build. I managed to sort it except for when a user asks for multiple tags (tags = 1, 2, 3). Product shown has to have all tags that the user asks (...
0
votes
0
answers
133
views
Laravel update query error using query builder with comma separeted values
I am getting the below error in the laravel controller when I update 4 columns with comma-separated values without quotes which are coming from the request
Request payload:
column1 : one,two,three
...
0
votes
1
answer
145
views
Typeorm query on ManyToMany relations
I'm trying to query over the table products to find, Certain products that have "at least" Category "Food", "Cold".
I hope someone can give me a hand to be able to query ...
0
votes
2
answers
29
views
Query combination in Laravel
i am facing a problem where my function have a request from the frontend for sorting the data. So i need to add some condition to my query. I tried to do this way.
$hawker = Hawker_location::...
0
votes
1
answer
318
views
PostgreSQL / TypeORM: search array in array column - return only the highest arrays' intersection
let's say we have 2 edges in a graph, each of them has many events observed on them, each event has one or several tags associated to them:
Let's say the first edge had 8 events with these tags: ABC ...
0
votes
0
answers
49
views
TypeORM - use multiple subQueries with queryBuilder
I need to use two subQueries to go through the table and find rows based on matches from two different columns.
Basically I have three tables for three custom entities. Let's call them EntityA, ...
0
votes
0
answers
219
views
How to query data from subquery table in typeorm
Here is what I want:
select * from (
select requester_id, CASE
WHEN requester_id = 'f791283d-43fd-484c-b11b-3360f436437c' THEN addressee_id
WHEN addressee_id = 'f791283d-43fd-484c-...
0
votes
0
answers
25
views
How to avoid conflict collection model in query builder union in laravel
I have 2 models Test and Exam; table related to these model have the same columns: id, name, point;
i want to retrieve the 2 data by using union:
$test = Test::where('point', '>', 10);
$exam = Exam:...
0
votes
1
answer
99
views
Laravel / Postgres - How to group by one column and select multiple columns?
I have FOR EXAMPLE laravel query builder:
DB::table('users')->select('name', 'phone', 'age')->groupBy('age')->...
How to do this query work?
The problem is that postgres can't group only by ...
0
votes
2
answers
268
views
Laravel query builder select all except specific column
I have 2 tables with the same columns except the second table have one more column, this column is foreign key of the first;
what i want is to make union query;but for union the column must the same; ...
1
vote
1
answer
30
views
How to build query from SQL by Doctrine QueryBuilder?
I'm new in Doctrine ORM, and I need help with building QueryBuilder command. I have a SQL command and I need covert to QueryBuilder.
$qb = $this->entityManager->createQueryBuilder();
The SQL is:
...
0
votes
1
answer
21
views
Codeigniter changes with `count_all_results`
So... it appears as if overnight, SOME-thing has changed with either the Codeigniter 4 framework or PHP in general, as my website is now down - and it seems to be centred around my call to a ...
0
votes
0
answers
89
views
Installation issues with react-awesome-query-builder
I'm trying to setup React-Awesome-Query-Builder over at npm , specifically the non TS version but using functional components together with MUI 5 widgets
The versions I have found are using TS and ...
0
votes
0
answers
44
views
Full text seach in Doctrine using query builder with no result hits
Specs:
Symfony v5.3.16
SQL Server 2017
Doctrine Bundle v2.4.4
Doctrine ORM v2.9.6
I've got a problem with full text search for SQL Server using Doctrine's query builder. I'm trying to use it with ...