I'm working in this query.
$data = RtvReqDet::find()
->joinWith(['header', 'rtvCard.serial sn', 'rtvCard.serial.item si', 'rtvCard.item ri' ])
->select([
'header.requested_by as classification',
'ifnull(sn.no, rtvCard.serial_no) AS serial',
'ifnull(si.no, ri.no) AS item',
'ifnull(si.uom, ri.uom) AS uom',
'COUNT(ifnull(sn.no, rtvCard.serial_no)) AS qty',
])
->where(['rtv_spare_parts_requisition_id' => $record->id ])
->groupBy(['serial'])->all();
It's working on Windows. But is not working on Linux and giving this error:
Exception 'yii\base\InvalidParamException' with message 'app\models\RtvCard has no relation named "serial AS sn".'
I tried lowering my php version and mysql version exactly with the Linux. but I can still transact on my windows. So it doesn't have any conflict with php and mysql version. what do you think is wrong with this?
this is the rtvCard model. This was customized by my colleague whom I've worked with before. I deleted some relations where I think not needed in this discussion.
<?php
namespace app\models;
use app\components\ActiveRecord;
use app\components\FieldException;
use yii\base\Exception;
class RtvCard extends ActiveRecord {
static function tableName() {
return "rtv_card";
}
static function objectName() {
return "rtv card";
}
// RELATIONS
function getCustomer() {
return $this->hasOne(Customer::className(), [ "id" => "customer_id" ])->from([ "customer" => Customer::tableName() ]);
}
function getSerial() {
return $this->hasOne(SerialNumbers::className(), [ "id" => "serial_id" ])->from([ "serial" => SerialNumbers::tableName() ]);
}
function getItem() {
return $this->hasOne(Items::className(), [ "id" => "item_id" ])->from([ "item" => Items::tableName() ]);
}
function getTransfer() {
return $this->hasOne(RtvTransferDetail::className(), [ "rtv_card_id" => "id" ])->from([ "transfer" => RtvTransferDetail::tableName() ]);
}
// USED FOR ERROR MESSAGES
static $attributeLabels = [
"id" => "ID",
"no" => "RTV No",
"item_id" => "Item",
"serial_id" => "Serial no.",
"defect_id" => "Defect",
"description" => "Complaints",
"date_received" => "Date received",
"received_by" => "Received by",
"customer_id" => "Dealer",
"reference_no" => "Reference no.",
"tag" => "Tag",
"technician_id" => "Technician",
"warehouse" => "Warehouse",
];
// FIELD NAMES IN VIEW IF NOT THE SAME WITH ATTRIBUTE
// USE STATIC::GET-FIELD($ATTRIBUTE-NAME)
// ATTRIBUTE NAME SHOULD BE THE TABLE ATTRIBUTES ITSELF ( NOT THE FIELD NAME IN VIEWS )
// ATTRIBUTE NAME => FIELD NAME
static $attributeFields = [
"item_id" => "item",
"serial_id" => "serial",
"defect_id" => "defect",
"customer_id" => "dealer",
"received_by" => "received-by",
"date_received" => "received-date",
"reference_no" => "reference-no",
"open_serial_id_no" => "no",
"open_serial_id_item" => "item",
"technician_id" => "technician",
];