如何在 OctoberCMS 的连接表中使用 where 子句?
How can I use where clause in the joined tables in OctoberCMS?
我在 Laravel 5 中使用 OctoberCMS。
我有几个模型,需要加入。
我有 'PaymentData' 型号和 'AppsData' 型号。它们都有 'mem_id' 列,我想根据 'PaymentData' 模型的数据从 'AppsData' 模型中获取 'app_process' 列的值。
我在下面尝试的操作导致了此错误消息。
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'app_process' in 'where clause' (SQL: select count(*) as aggregate from BYAPPS_apps_payment_data
where pay_type
!= 1 and amount
= 0 and app_process
!= 8)" on line 664 of /home/ljw/public_html/byapps_cms/vendor/laravel/framework/src/Illuminate/Database/Connection.php
支付数据模型
class PaymentData extends Model
{
use \October\Rain\Database\Traits\Validation;
public $table = 'BYAPPS_apps_payment_data';
public $rules = [
];
public $hasOne = [
'joins' => [
'Jiwon\Byapps\Models\AppsData',
'key' => 'mem_id',
'otherKey' => 'mem_id'
]
];
}
AppsData 模型
class AppsData extends Model
{
use \October\Rain\Database\Traits\Validation;
public $table = 'BYAPPS_apps_data';
public $rules = [
];
}
我在home.htm
中尝试了什么
use Jiwon\Byapps\Models\AppsData;
use Jiwon\Byapps\Models\PaymentData;
function onGetAppChartData()
{
$this['appsFree'] = PaymentData::where('pay_type', '!=', '1')
->where('amount', '=', '0')
->where('app_process', '!=', '8')
->count();
}
我在这里做错了什么?请有人帮助我...!_!
您可以尝试编写这样的自定义查询:
$this['appsFree'] = \DB::table('BYAPPS_apps_payment_data as p')
->join('BYAPPS_apps_data as a', 'a.mem_id', '=', 'p.mem_id')
->where('p.pay_type', '!=', '1')
->where('p.amount', '=', '0')
->where('p.app_process', '!=', '8')
->count();
我在 Laravel 5 中使用 OctoberCMS。 我有几个模型,需要加入。
我有 'PaymentData' 型号和 'AppsData' 型号。它们都有 'mem_id' 列,我想根据 'PaymentData' 模型的数据从 'AppsData' 模型中获取 'app_process' 列的值。
我在下面尝试的操作导致了此错误消息。
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'app_process' in 'where clause' (SQL: select count(*) as aggregate from
BYAPPS_apps_payment_data
wherepay_type
!= 1 andamount
= 0 andapp_process
!= 8)" on line 664 of /home/ljw/public_html/byapps_cms/vendor/laravel/framework/src/Illuminate/Database/Connection.php
支付数据模型
class PaymentData extends Model
{
use \October\Rain\Database\Traits\Validation;
public $table = 'BYAPPS_apps_payment_data';
public $rules = [
];
public $hasOne = [
'joins' => [
'Jiwon\Byapps\Models\AppsData',
'key' => 'mem_id',
'otherKey' => 'mem_id'
]
];
}
AppsData 模型
class AppsData extends Model
{
use \October\Rain\Database\Traits\Validation;
public $table = 'BYAPPS_apps_data';
public $rules = [
];
}
我在home.htm
中尝试了什么use Jiwon\Byapps\Models\AppsData;
use Jiwon\Byapps\Models\PaymentData;
function onGetAppChartData()
{
$this['appsFree'] = PaymentData::where('pay_type', '!=', '1')
->where('amount', '=', '0')
->where('app_process', '!=', '8')
->count();
}
我在这里做错了什么?请有人帮助我...!_!
您可以尝试编写这样的自定义查询:
$this['appsFree'] = \DB::table('BYAPPS_apps_payment_data as p')
->join('BYAPPS_apps_data as a', 'a.mem_id', '=', 'p.mem_id')
->where('p.pay_type', '!=', '1')
->where('p.amount', '=', '0')
->where('p.app_process', '!=', '8')
->count();