Questions tagged [query-builder]

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

1
vote
4answers
62 views

How can i create a conditional check in laravel query

hi how can we implement a condition checks in laravel query builder $flag_email =true; $query = DB::table('customer'); if($flag_email) { $query->where('email','=',$email); } if(!$...
0
votes
0answers
15 views

Query builder “addSelect” affects “addOrderBy”

I have Symfony 4 width Doctrine, two entities/tables with relation Fixture (one) - Picture (many). Both tables has column with name "order". I am loading (eagerly) all fixtures and its pictures. I am ...
-3
votes
0answers
36 views

Query builder where and mysql

I am trying to create a query that searches for first and last name. Here is my original query. $em = $this->getDoctrine()->getManager(); $qb = $em->createQueryBuilder(); $qb ->select('...
-3
votes
1answer
30 views

How to check & set custom field value in redmine?

The problem: I am working on importing a CSV file to Users. And I want to create them a custom field "display order", and populate it if such custom field exists for model Users. What I've done to ...
2
votes
3answers
150 views
+100

How to join multiple entities on a foreign ID in Symfony 4 using a query builder?

I'm trying to learn Symfony. Today I was following The associations tutorial. I decided to make a small application that a House, Kitchens, Bedrooms, and cabinets. I (tried to ;-) ) make a small Class ...
2
votes
0answers
29 views

How to migrate MySQL REPLACE to TYPO3 QueryBuilder?

im refactoring a pretty ancient TYPO3 extension codebase from pibase to extbase. one part is to rework the old mysql approach from $GLOBALS["TYPO3_DB"]->sql_query("...") to $queryBuilder = ...
0
votes
1answer
34 views

Sum amount of one day period

I am trying to sum the total amount of user payments for one day period (24 hours..) My query is returning all results even if dates are far from 24 hours range. How to fix this? resultDaily = $...
0
votes
1answer
48 views

Controller to be able to search for first and last name

I am trying to make this controller more dynamic by allowing the controller to be able to make a search with First and Last name. Right now, the controller only search by first name and last name and ...
-3
votes
2answers
31 views

Invalid parameter: token account is not defined in the query

I have two query builders defined. First: Returns all accounts of an user. Seconds: Returns all user transactions by account. First: public function getAccountsList($user) { return $this->...
0
votes
0answers
22 views

Query filter api in Symfony

I am trying to create an endpoint that queries from a filter list and spits out the results. The below code send all the results back but i am trying to create something where i can use $filter=...
0
votes
2answers
35 views

Fulltext query on properties and subnodes does not work properly - AEM Query Builder

I'm trying to perform a query on the CRX of a 6.2 Adobe AEM version. I have to execute a fulltext query on (aNode is a generic subnode of /content/connect/it/supplier/): 1) all properties of /...
0
votes
1answer
33 views

method _or in Cake\Database\Expression\QueryExpression giving 'AND' Instead of 'OR' when i called sql() method

I am trying to add OR SQL Query Statement to my CakePHP project, but notice I am getting AND instead of OR. I am getting this string when I use SQL(), and no OR is include whereas OR is expected ...
0
votes
0answers
27 views

Does eagerCursor() in Symfony (query builder) - MongoDb - Doctrine ODM have any disadvatages. Does it affect overall performance of symfony?

I am Using eagerCursor() in createQueryBuilder to avoid a for loop and collect the ID's using single group query. It Speeds up that specific function very much, I feels like overall application is ...
0
votes
1answer
36 views

Laravel: select data based on other data in another table

I'm working on Bus Station Management System. and i'm trying to queue bus in Schedule. so what i want is this: i want to display all buses of specific station that are not in queue of specific ...
0
votes
1answer
33 views

How to get last inserted IDS of multiple insert in Knex.js?

I need to get all last inserted IDS while inserting multiple records at a time but right now I'm getting only one ID. const data = await querybuilder('surveyresponse').insert(varList) Output: [183]...
1
vote
1answer
25 views

How to improvise on heavy should queries in huge data set?

My task involves using elastic search (5.6) for running queries of the format word1 AND word2 AND word3 QueryBuilder builders = QueryBuilders.boolQuery() .must(...
1
vote
2answers
59 views

Selecting data so that it only returns the latest row per ID

I'm currently working on my first Laravel project and I'm working with a database that has rows like this: id message timestamp 1 first 1500000000 1 second ...
0
votes
3answers
34 views

Retrieve data between dates in laravel

I am using an eloquent query to retrieve data from a table. The table columns look like this: id started_at finished_at 1 06/02/2019 06/15/2019 2 06/05/2019 06/11/2019 What I want to ...
1
vote
1answer
30 views

KnexJS How to create multiple inner join

I need to transform this SQL query to KnexJS query SELECT Book.Title, Book.Number, Author.Name, Author_1.Name, Author_2.Name, Author_3.Name FROM ((((Book) INNER JOIN ...
1
vote
2answers
39 views

how to select from database using an array in condition in laravel

I have an array called $slugs and I need to receive data form database table called posts in single array how to archive that ?
0
votes
1answer
43 views

Query relation and group by in query builder

Getting a sql error in my query, i believe maybe is malformed my query builder but cant figure out what im doing wrong. Alredy tried testing my query directlly in the DB and it works, but when ...
0
votes
1answer
22 views

Convert query build to native SQL with union

I made two count queries with query build doctrine but after I found that there is several query count that repeats so I must work with UNION but there is no union in doctrine query build. So the ...
0
votes
2answers
62 views

Understanding problem Doctrine 2 ORM Query Builder in Symfony 4

I hope there are a few helpful and prefer German Symfony experts. For many years I have been working with PHP and now I tryed in a framework. I chose Symfony now because I like the components the most....
0
votes
0answers
32 views

three query build in one

I create three query build queries, I try to combine them into a single query doctrine but I do not know how to achieve the purpose of creating a single request is to eliminate the round-trip client ...
0
votes
2answers
46 views

Query Build doctrine Symfony

I have 2 entity (Rule and analysisRule)( association one to many) I try to make a query that counts the number of idAnalyseRule that have an idAnalyse pass as a parameter in the function example: I ...
0
votes
0answers
39 views

I cannot use Doctrine Expr correctly

I want to change this query to doctrine but I couldn't. select * from table1 left join table2 on table2.hotel_id = table1.id left join table3 on table2.table3_id = table3.id left join ( select ...
1
vote
0answers
29 views

Native Query OR DoctrineExtensions for mysql-functions

In general, I would like to extend the query builder to MySql functions or send nativie queries. I want to get all records from the sys_category_record_mm table with several categories. For this I ...
0
votes
1answer
46 views

How to reference columns to order a union query?

I have done a Union in cakephp 3, however the union is doing it such that the buyers table records are shown first and then the tenants. Whereas i want it to be arranged based on created field in ...
0
votes
1answer
23 views

How to write mysql join sub query from 5 tables in laravel controller

I have a MySQL query like bellow, and I want to use it in laravel controller, I know how to use join in laravel, but I don't know how to write it when we have another sub query in the join statement,...
0
votes
1answer
25 views

How to inject joined object in doctrine 2 using query builder

I have Article and Category entities. That entities not related by mapping but i need join Category to Article using query builder and as result i need Article entity with injected in Category entity. ...
0
votes
1answer
29 views

How to transform SQL (nested subquery) to query created by QueryBuilder

Is this possible to create a query by JPA QueryBuilder using query.from(subquery)? select DISTINCT substring(min(sel."order"), 2) from (SELECT s.name || d.name "name", CASE WHEN ...
0
votes
1answer
22 views

How to parse PHP Doctrine Querybuilder DateTime from a HTTPResponseMessage to C# DateTime?

I am trying to pass a SQL result from my PHP-made website to my C# APP that I'm making with Xamarin Forms. I've done this by making A REST API endpoint in my PHP application and therefore calling the ...
0
votes
2answers
25 views

Laravel Query Builder left join

can someone please tell me, why i am not able to select section from sections table using left join. i want list of teachers in a table, i am able to access all data from teachers table, but i am not ...
0
votes
3answers
51 views

Apply where condition only to one occurrence

I'm building search functionality for my app. To simplify things: there are two tables: shops and subscriptions Each shop can have multiple subscription records, subscription has field expires_at. ...
1
vote
1answer
47 views

QueryBuilder issue with JOIN

i have a problem with the Doctrine queryBuilder. I have two entites : Donations, and Donateurs. I just want to do a left join (because Donations.donorId refer to Donateurs.id, for example.) The query ...
1
vote
2answers
64 views

How to use WITH clause in Laravel Query Builder

I have SQL query (see example). But I can't find a way how I can write it in Query Builder. Do you have any ideas how is it possible? WITH main AS ( SELECT id FROM table1 ) SELECT * FROM table2 ...
1
vote
2answers
70 views

Is it possible to builk insert ignore / insert or update with eloquent or query builder in Laravel 5.8? Without looping each record?

Im generating a lot of data that i would like to store in DB, sometime part of data that i would store already exists in DB. How can i insert bulk amount of records without looping them all?
1
vote
1answer
24 views

doctrine2 querybuilder not between

I'd like to make a MySQL query with doctrine2 QueryBuilder (Symfony 3.4 app) with a NOT BETWEEN statment. The doctrine provide a ->expr()->between(..) but not ->expr()->notBetween(..) Is ...
0
votes
1answer
17 views

Symfony Doctrine - Object of class stdClass could not be converted to string

I wrote some complex api to return results from stdClass objects in my controller. That part works fine. Then, in my service I wrote a query builder that needs to restrict results to 6 months period....
0
votes
0answers
19 views

no such file or directory, scandir '/sql/' issue var sql = new SQLBuilder('SQLServer'); on creating the object of json-sql-builder2 module

I'm getting this below error on deploying my aws lambda package on node 8.10.0 but it works fine in my local windows. let modules = tools.walk(path.join(__dirname, `../sql/`)); on logging the ...
0
votes
2answers
96 views

Symfony Form Query Builder

I have a problem with my query builder but I do not know how to fix this error can you help me please? So here is my problem, I want to retrieve the list of questions that are not in my questionnaire ...
0
votes
1answer
46 views

Call to undefined method Illuminate\Database\Query\Builder::passengers()

I want to seed my db that shows me this error: Call to undefined method Illuminate\Database\Query\Builder::passengers() this is databse seeder: public function run() { // $this->call(...
0
votes
1answer
25 views

SQL left join error in laravel query builder

My code is selecting all data from teachers table and showing only id's from connected tables instead of nations name. when i try to select any table except teachers it doesn't work. public static ...
1
vote
1answer
38 views

Backend returns error when left join fields are empty

I have a query to return company details, but if the field used for left join is empty query returns error .How to solve this? I tried, ->leftJoin('company.field1', 'field1') ->leftJoin('...
0
votes
2answers
51 views

How to get a single value from Query Builder in Laravel?

I'm trying to get a single value from Query Builder in Laravel but the problem is I'm getting an array. this is my query result in Postman with dd($myVar): [{"is_liked":1}] and also with echo($...
-1
votes
2answers
46 views

How to Convert SQL to Laravel Query

I want to build something with an aliases column like below, but I don't know how to make it a Laravel query. The following is my SQL. SELECT d.*, d.damaged_building, d.total_victim FROM ...
0
votes
2answers
57 views

Two variable in one one variable

I have two queries. $createdServer = Server::where('created_at', '>=', \Carbon\Carbon::now()->subMonth()) ->selectRaw('COUNT(id) as createserver, DATE(created_at) as date,DAY(created_at) ...
0
votes
0answers
65 views

Cannot read property 'getParameters' of undefined

I'm currently trying to connect my frontend Ionic application with my Node.js backend application. The connection between the apps have been tested before and already deployed to Azure (which works ...
0
votes
0answers
15 views

Laravel Query builder - multiple sum() issue

Hei there, I'm new in laravel and I have some issues with laravel query builder. The query I would like to build is this one: Select nofaktur, date, diskon, namacust, SUM(subtotal)+SUM(diskon)) as ...
0
votes
0answers
7 views

Alias to id field

Using Symfony 3 want to alias my user avatar to id, so I will get an array where my keys will be ids and values the field $qb->innerJoin('u.info', 'i'); $qb->addSelect('i.avatar as id'); this ...