creating mysql query using Yii2 Query Builder, strpos: array given
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I'm trying to make query builder to output the following MySQL query: , The reason of the error is in this section of code: ->innerJoin([
'p2' => (new Query)
->select(['MAX(updated_at) MaxDate', 'product_id' ])
->from('tbl_scrape_data')
->where([ 'product_id' => [1, 2, 3, 15, 4] ])
->groupBy('product_id'),
//->all(),
['p1.product_id' => 'p2.product_id', 'p1.updated_at' => 'p2.MaxDate']
])
->innerJoin(
['p2' => (new Query)
->select(['MAX(updated_at) MaxDate', 'product_id' ])
->from('tbl_scrape_data')
->where([ 'product_id' => [1, 2, 3, 15, 4] ])
->groupBy('product_id'),
//->all(),
],
['p1.product_id' => 'p2.product_id', 'p1.updated_at' => 'p2.MaxDate']
)
|
Yii2 and sqldataprovider in inner query, write one aggregating expression per reporting column, 2. In an outer query, bu
Tag : yii2 , By : amorican
Date : March 29 2020, 07:55 AM
Hope this helps Please check the following blog about yii2. Yii2 and Pivot Tables to SHANEESH P PALLIYALIL, he has been very halpful.
|
Yii2 using data from array in query
Tag : php , By : Boyer C.
Date : March 29 2020, 07:55 AM
it fixes the issue I have this bit of code which finds the ID of the logged in user, finds all of the customers that are related to that user and stores the 'custref'(id) into an array: , Here is the shortest way. $chanId = Yii::$app->user->identity->typedIdentity->getId();
$customerArray = Customer::find()->where(['channelref' => $chanId])->all();
$ref = yii\helpers\ArrayHelper::map($customerArray,'custref','custref');
$query = $model::findNongeo()->where(['custref'=>$ref])->all();
$query = $model::findNongeo()->where(['in', 'custref', $ref])->all();
|
Will cloning model query avoid recalling of MySQL query in Yii2?
Date : March 29 2020, 07:55 AM
hop of those help? It does not matter if you clone query or not. sum() performs actual SQL query - if you call it three times, you will get three queries. From microptimization perspective clone should be faster than creating the same query object three times. But you will not see much difference - performing real SQL query will be main bottleneck here, PHP overhead will be negligible.
|
Yii2 query mysql, Adding A Column that doesn't exist in a query
Tag : mysql , By : Vodkat
Date : March 29 2020, 07:55 AM
|