query-builder Questions
3
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 cu...
Vesiculate asked 17/4, 2019 at 19:46
3
Solved
In one of the my worker scripts to store aggregate counts based on some metrics, I am not using Eloquent as the queries are a little complex and and it is easy to write using query builder. I am cu...
Anthodium asked 10/6, 2016 at 6:4
1
Solved
I have the following saved json data in Elasticsearch:
{
"id":"1234",
"expirationDate":"17343234234",
"paths":"http:localhost:9090",
...
Altruistic asked 22/10, 2020 at 18:24
2
Solved
I have the following sql query
SELECT * FROM exams WHERE exams.id NOT IN (SELECT examId FROM testresults)
how can I convert it into Laravel query builder format?
Thanks.
Frightened asked 6/2, 2015 at 8:25
3
Solved
I need to get all rows where DATE(a.when) matches the string 2014-09-30.
$builder = $this->em->createQueryBuilder();
$builder->select('a')
->from('Entity\Appointment', 'a')
->andW...
Kinnikinnick asked 23/9, 2014 at 14:53
3
Solved
here it is:-
$query = Section::orderBy("section", "desc")->get();
section here is a column with type string yet it is having numbers in it where i want to order by those num...
Fuzzy asked 11/8, 2020 at 8:59
5
Solved
I'm trying to upgrade my project L5.1 -> L5.2. In upgrade guide there's one thing which isn't clear for me:
The lists method on the Collection, query builder and Eloquent query
builder objects ...
Potentiometer asked 21/12, 2015 at 22:7
3
Solved
how to express this code in query builder. I'm using Laravel 6.
SELECT * FROM feedback GROUP BY noTicket having count(`status`) < 2
My Code:
$feedback = DB::table('feedback')
->groupBy(...
Wildee asked 4/6, 2020 at 7:18
1
Solved
I have a query:
topics = await topicRepository.createQueryBuilder('topic')
.leftJoinAndSelect('topic.user', 'user', 'topic.userId = user.id')
.where('topic.categoryId = :id', {
id: categoryId,
...
Dietetics asked 19/1, 2020 at 17:1
4
Solved
I have this symfony code where it retrieves all the categories related to a blog section on my project:
$category = $catrep->createQueryBuilder('cc')
->Where('cc.contenttype = :type')
->...
Signpost asked 25/8, 2011 at 9:45
8
Solved
I did some performance tests between Laravel's DB facade query builder and Laravel's Eloquent ORM. The DB facade was much faster than Eloquent for many SQL statements (SELECT, UPDATE, DELETE,...
Pectoralis asked 15/7, 2016 at 8:44
2
Solved
I'm building a very simple web app with Laravel.
I've built two separate Controllers, which each return two separate views, as follows:
ProfileController:
class ProfileController extends BaseCon...
Fabrice asked 27/1, 2015 at 17:24
2
Solved
I have a belongsToMany association on Users and Contacts.
I would like to find the Contacts of the given User.
I would need something like
$this->Contacts->find()->contain(['Users' =>...
Typebar asked 7/11, 2014 at 10:27
1
Solved
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 Author ON Book.AuthName...
Tabby asked 1/6, 2019 at 16:4
1
Solved
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. instruct pypika which DB to use, which credentials etc....
Farias asked 10/4, 2019 at 8:44
6
Solved
In Laravel 5.1, for MySQL insert, I want to see if the record already exists and update on duplicate or create new if none exists.
I have already searched SO where the answers were for old laravel...
Yvette asked 25/7, 2015 at 8:20
4
I want to set null to a field in doctrine and here is the sentence
$em = $this->getDoctrine()->getManager();
$qb = $em->createQueryBuilder();
$query = $qb->update('Model\Example', 'u')...
Imposing asked 28/11, 2013 at 14:55
4
Solved
How do you make it where in clause in new CakePHP? I'm trying:
$restaurants->find()->where(['id' => $r_ids])->all();
Where $r_ids is array of ids I need in my query, but this doesn't...
Filagree asked 12/11, 2014 at 12:54
2
Solved
I have an entity Offer. Offer has a ManyToMany Relationship to Files.
Now I want to have all Offers, that have files -> Count(offer.files) > 0.
I tried it like this, but doesn't work:
$this->r...
Lucretialucretius asked 15/10, 2018 at 8:59
2
I have an application that use 2 databases. I need to create a query that joins a table from one database with a table form another but I don't know how to do that.
So, I have a connection name my...
Arella asked 4/10, 2018 at 10:58
1
I have 4 tables.
User table:
id col1 col2
CoursesAssigned table:
id user_id course_id approved
CourseInfo table:
id parent_id
CourseParents table:
id start_date end_date
I think the ...
Uncaused asked 3/9, 2018 at 11:37
2
I'm using Laravel 5 and I have a table of users, and two tables 'clients' and 'employes' which contain relations between users.
I would like to get all the clients and employees of the logged in u...
Vassily asked 22/8, 2016 at 10:50
3
Solved
I would like to execute the follow sentence using laravel eloquent
SELECT *, count(*) FROM reserves group by day
The only solution occurs to me is to create a view in the DB, but I am pretty sur...
Dainedainty asked 16/1, 2016 at 14:12
2
Solved
I have two entities User and CalendarEvent. My users are attached to a factory, and calendarEvent can be used to know if a user is "loaned" to a different factory of the one he belongs to...
My tw...
Shoulders asked 12/6, 2018 at 10:35
1
I'm trying to write the following code:
foreach($relations as $relation){
$query->orWhereHas($relation, function ($query) use ($filter) {
$query->where('name', 'like', '%'.$filter.'%');
...
Eventide asked 26/10, 2016 at 21:0
© 2022 - 2024 — McMap. All rights reserved.