Questions tagged [raw-query-builder]

10 questions
4
votes
3 answers

cannot perform raw query with DB::select(DB::raw()) after updating to laravel 10

after updating to laravel 10, i cant perform raw query like this: $statement = 'SELECT'; foreach ($tables = collect(availableTables()) as $name => $table_name) { if ($tables->last() == $table_name) { $statement .= "( SELECT…
arya_la
  • 399
  • 2
  • 10
0
votes
0 answers

Get the translation map as column name in django raw query

Below is my raw query using Django Model and data from mysql legacy_mapping = { 'link_desc.id':'link_desc_id', 'sub_category.name':'sub_category', 'total_work_days.total_days':'without_recasting_days', …
Deepika Rao
  • 145
  • 1
  • 3
  • 11
0
votes
0 answers

DB::raw query in laravel not working using oracle

I am trying to integrate oracle in my laravel project. There are some condition which need to do by raw queries. I tried DB::raw, DB::select, DB::select but none of them are working. I am getting this if I use DB::raw approach: { "data":…
0
votes
1 answer

Calculate the average on runtime from the query in laravel

I want to calculate the average of daily gc_score obtained from the below query: $query = DB::table('qc_feedbacks') ->selectRaw(" COUNT(cru_agent_detail_id) as numberofEvaluations, COUNT( CASE WHEN qc_feedbacks.status='Passed'…
0
votes
1 answer

set where condition only if left join table has value

this is my query: DB::table('attribute_model_values')->select([ 'attribute_model_values.value', 'attribute_model_values.model_id as p_id', 'attribute_values.title as v_title', …
arya_la
  • 399
  • 2
  • 10
0
votes
0 answers

sequelize how to write replacement in insert value correctly?

I want to insert some values in the database but I got an error about syntax as following: sysntax error at or near ":"; How to properly add the replacement? Whrere is this error caused from? I watch also the sequelize documentation here How make…
FaFa
  • 358
  • 2
  • 16
0
votes
0 answers

Does sequelize 7.0.0-alpha.4 prevent sql injection with mysql raw query?

I am using below code for update but i need to prevent sql injection in this query. const query1 = `UPDATE Table SET name='xyz' WHERE id=1`; const saveEditPost = await sequelizeWrite.query(query1, { type: sequelizeWrite.QueryTypes.UPDATE }); How to…
0
votes
1 answer

Laravel calculate the value inside wherehas and return data

$credits = User::select('id','username')->where('id', auth()->id()) ->with(['game_credits' => function($query) use ($phase){ $query->select('user_id','no_of_game_played','game_credits') ->where('phase_id',…
-1
votes
1 answer

get users who followed each other by MySQL query

I want to get name, email, id of both users who followed each other and status equal to 'A'. My friends table screenshot: Note: In the above screenshot follower_id and following_id are both users table ids.
M-Khawar
  • 855
  • 5
  • 17
-1
votes
2 answers

How to print date without time in laravel?

The following query is giving me time with date but i need only date .How do I do? $data = DB::table('kahanighar_ivr.kahani_cdr') ->select(DB::raw('count(*) as a'),'dst','calldate as ibdate',DB::raw('"kahani" as ser')) …