Questions tagged [query-builder]

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

1
vote
1answer
19 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
21 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
50 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
45 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
49 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
52 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
20 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
12 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
18 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
76 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
37 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 ...
0
votes
1answer
34 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
45 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
45 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
55 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
14 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 ...
0
votes
0answers
21 views

Subquery in JQuery QueryBuilder

I am going to use the JQuery Query Builder plugin in my project. I want to know how query will generate for relational table. For example, I have two tables user and user_emails. I want to filter ...
0
votes
1answer
47 views

How to fix Laravel bulk inserting records only saving first record to database

I am trying to save multiple records to database. I think there must be something wrong with submitting array from front-end view. Firstly, my rows are dynamically generated with jquery. I have ...
3
votes
1answer
76 views

Dynamic query selection on a list contains list

I am trying to make a dynamic filtering mechanism with c#. I have user class with properties like Name, Surname, BirthDate etc. and Also UserInformations list which is a list of a UserInformation ...
-1
votes
2answers
19 views

How to check if querybuilder (sql) has “GroupBy” part

how to check if doctrine querybuilder has groupby part? For me is important only group by on end of sql, not in inner-select... I must set other reaction in script for sql with groupby and without ...
0
votes
0answers
10 views

Symfony - gedmo translatable can't find table

It seems everything works fine except the where I want to dump() translate data from my table. Data is there and now I need to return translated results but it throws: An exception occurred while ...
2
votes
2answers
46 views

I have probleme in query builder SYMFONY

I want to search an user by "firstname" and "lastname" so at first i have an input text where i put the lastname and firstname in the same input and second i have created this query public ...
2
votes
0answers
21 views

Removing default fields from java elasticsearch querybuilder

Elasticsearch Java client's QueryBuider instance is adding properties like 1) order 2) min_doc_count 3) shard_min_doc_count 4) show_term_doc_count_error 5) lang 6) gap_policy to the final Json query. ...
0
votes
2answers
33 views

Set parameter as int array for where in statement in dbal query builder throws array to string conversion exception

I try to bind parameter : [1, 2] in dbal querybuilder in WHERE IN statement I tried to change $qb->expr()->in() to string version but nothing changed QueryBuilder creation $qb = $this->_em-...
1
vote
2answers
55 views

Laravel Eloquent - Merging two eloquent model results (not the collections)

I have a table of stock movements, which shows a history of a product (receiving, moving location etc.) I have two queries which calculate (via aggregate sums): The original received qty. The ...
0
votes
2answers
22 views

Laravel query builder - using data within row to compare with time in another

I have got this working using a whereRaw as follow: Reports::whereRaw('last_check_datetime < CURRENT_TIMESTAMP - INTERVAL `check_schedule_minutes` MINUTE')->get(); The table has a number of ...
0
votes
1answer
52 views

How to access the transaction of the current context while extending QueryBuilder class in Knex

Im trying to extend the QueryBuilder of Knex.js. I want to modify the delete() method in order to delete the child elements of my Objection.js Model. Current code works well, but I want to support ...
0
votes
1answer
41 views

How reuse formatted Doctrine 2 with QueryBuilder formatted query in other query

I have formatted query with doctrine query builder. It is kind of complicated because in that query there are some my own defined doctrine functions and doctrine extensions. Also very important to ...
0
votes
2answers
40 views

Eloquent - Detect multiple column duplicate data

I have a table that has 3 column id, sub_id, name. That is a pretty big table and there are some duplicates. What is the best way to detect the duplicates so that I can remove them? I tried this but ...
1
vote
1answer
71 views

Doctrine left join with priority on language field with querybuilder

I'm using the query below: use Doctrine\ORM\Query\Expr\Join; $query = $this->createQueryBuilder('ad') ->select('ad.id, ad.title, ad.year, ad.hours, ad.status') ->addSelect('rem....
0
votes
1answer
32 views

Problem with the datepicker plugin in QueryBuilder

I'm using QueryBuilder and I have a search that is of type date. The problem is that I'm getting an error because of the Plugin Datapicker, but I do not know what the reason for the error, can anyone ...
0
votes
2answers
39 views

Effiecient way to get data from database in foreach

I am loading data from excel. In foreach I am checking for each record if it does exist in database: $recordExists = $this->checkIfExists($record); function checkIfExists($record) { $...
-1
votes
2answers
42 views

How to select data with query builder when have many to many relations?

I use Symfony 3.2 and Doctrine Query Builder. I have ManyToMany Relationship between (Users<->roles_users<->Roles) users(id), roles_users(role_id, user_id) and roles(id, name). And want ...
0
votes
0answers
32 views

How to bulk update related records in cakephp3?

Can somebody help me with the correct approach on updating multiple records related to a table and based on a condition. I am trying to update the field is_deleted for all comments in comment table, ...
1
vote
1answer
36 views

Object of class stdClass could not be converted to string in Laravel?

I tried filtering data based on the 'Jadwal_kuliah' and 'khs' tables but I found an error "The object of the class stdClass could not be converted to string" : function jadwal_kuliah_json() { $...
0
votes
0answers
11 views

How to convert SQL with join and subquery to CriteriaBuilder query?

I have the next SQL query SELECT cb.id cbId, cb.name cbName, d.id drugId, d.name drugName, array_agg(sel.id) dependencyDrugIds FROM businesses cb LEFT JOIN scenarios s ON cb.id = s.cb_id LEFT ...
0
votes
3answers
46 views

Write query with subquery in CodeIgniter Query Builder?

I have the following query which has an issue with Query Builder. SELECT Sum(TEMP.total) AS total_amount FROM (SELECT Ifnull(t3.amount, t1.amount) AS total FROM table1 AS t1 ...
2
votes
1answer
62 views

python pypika - connect to the database

Actually I have a very generic question about using pypika. Reading the documentation it's pretty much clear how to build queries, but I couldn't find any tutorial how to connect to the database - i.e....
0
votes
1answer
59 views

Update data from a query using multiple where in laravel

I have a 2d array input like this: [ 6 => [ [2=>3, 5=>7] ], 8 => [ [1=>4, 9=>3] ], ..... ] The 6,8 are locationIDs and 2,5,1,9 are variantIDs and 3,4,7,3 are their respective ...
0
votes
0answers
40 views

How Can I perform a check to see if a record has a foreign Key?

Is there some way to perform a check whether to see or not if a table record has a foreign key before I delete it or update it?. I have this code using a delete: But I get this error: "SQLSTATE[...
0
votes
0answers
48 views

How to filter data from database based on Calculations?

I tried to make a learning, and in learning there was a lesson. But I am confused about how to display the repeated data, I've tried it but it can't be displayed. Next is the Controller function ...
0
votes
0answers
21 views

leftJoinAndMapOne does not add target property to entity

i have 2 tables word | word_id | word_str | | --- | --- | | 123 | hello | remember |remember_id| word_id |score | | --- | --- | --- | | 321 | 123 | 100 ...
0
votes
1answer
23 views

Linking a query criteria to a value in a local table

I have a 5 column table with thousands of rows that I need to be able to filter. In the form where the table is displayed, Form1, I have a text field, Value1, where the table will only display the ...
0
votes
1answer
45 views

I have 2 time in PHP, how can I run a foreach loop to go through all of those days? (1 Hour loop same time Last 24 Hours!)

I'm starting with a time now() and ending with last 24 Hours. How can I iterate through all of those times in PHP? One time each same time one and second time loop started...
0
votes
2answers
16 views

Use Subquery on Where IN with Multiple addSelect

I have create a subquery and a query with querybuilder and i need to use the subquery with where in, but my subquery use multiple select and i don't know how to handle that. My subquery with ...
0
votes
2answers
31 views

QueryBuilder lastInsertId()

I would like to have the last UID of the entry. For mysql, it is "insertId()". How does that work at Extbase? $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->...
0
votes
1answer
42 views

Subquery returned more than one value, =, !=, <, <=, >, >=

Implementing a sub query in a query, that returns the last loan remove of a DVD by using max(dateOut). The query gives the correct return in the loan table, however when trying to implement as a ...