我有以下要保存到数据库的数组。
$this->ProgramApplication->saveMany($priApps);
$priApps:
Array
(
[0] => Array
(
[ProgramCurrentResidence] => Array
(
[program_id] => 3698076220130520
[customer_id] => jraer4081
[residence_duration] => 61-90-days
[residence_stability] => renting-leasing
[payment_current] => yes
[payment_amount_past_due] =>
[landlord_name] => Blake Woods
[landlord_phone] => (269)777-7777
[landlord_fax] =>
[notes] =>
)
[ProgramPreviousResidence] => Array
(
[program_id] => 3698076220130520
[customer_id] => jrayner4081
[residence_duration] => 1year
[street_address] => 1637 Colfax Ave
[city] => The Harbor
[state] => me
[zip] => 49022
)
)
)
一直抛出以下错误...
数据库错误
错误:SQLSTATE [42S22]:找不到列:1054“ where子句”中的未知列“ ProgramCurrentResidence.program_id”
SQL查询:SELECT
ProgramApplication
。program_id
,ProgramApplication
。customer_id
,ProgramApplication
。secondary_customer_id
,ProgramApplication
。secondary_customer_relationship
,ProgramApplication
。sales_associate
,ProgramApplication
。,store
。ProgramApplication
,created_on
。ProgramApplication
,date_submitted
。ProgramApplication
,date_delivered
。ProgramApplication
,stock_number
。ProgramApplication
,deal_status
。ProgramApplication
, deal_status_conditional_reasoning
。ProgramApplication
,transfered_to_dealpack
。ProgramApplication
,presubmittal_notes
。ProgramApplication
,underwriters_notes
。ProgramApplication
从modified_by
。expreta2_x12
AS programs
在哪里((ProgramApplication
。 ProgramCurrentResidence
='3698076220130520')AND(program_id
。ProgramCurrentResidence
='jrayner4081'))限制1这是我的ProgramCurrentResidence模型...
<?php
class ProgramCurrentResidence extends AppModel {
public $useTable = 'program_current_residences';
public $primaryKey = 'program_id';
public $belongsTo = array(
'ProgramApplication' => array(
'foreignKey' => 'program_id'
)
);
}
?>
程序应用程序模型中的一些代码
<?php
class ProgramApplication extends AppModel {
public $useTable = 'programs';
public $primaryKey = 'program_id';
public $actAs = array('Containable');
public $belongsTo = array(
'Inventory' => array(
'foreignKey' => 'stock_number'
),
'Customer' => array(
'foreignKey' => 'customer_id'
),
'Employee' => array(
'foreignKey' => 'sales_associate'
),
'CustomerPersonalInformation' => array(
'foreignKey' => 'customer_id'
),
'CustomerContactInformation' => array(
'foreignKey' => 'customer_id'
),
'CustomerMarketingOption' => array(
'foreignKey' => 'customer_id'
)
);
public $hasOne = array(
'Desklog' => array(
'foreignKey' => 'program_id'
),
'Funding' => array(
'foreignKey' => 'program_id'
),
'ProgramCurrentResidence' => array(
'foreignKey' => 'program_id'
),
'ProgramPreviousResidence' => array(
'foreignKey' => 'program_id'
),
'ProgramCurrentEmployment' => array(
'foreignKey' => 'program_id'
),
'ProgramPreviousEmployment' => array(
'foreignKey' => 'program_id'
),
'ProgramIncome' => array(
'foreignKey' => 'program_id'
),
'ProgramReference' => array(
'foreignKey' => 'program_id'
),
'ProgramAdditionalInformation' => array(
'foreignKey' => 'program_id'
),
'ProgramDoublePreviousEmployment'=> array(
'foreignKey' => 'program_id'
),
'ProgramDoublePreviousResidence'=> array(
'foreignKey' => 'program_id'
),
'ProgramExpense'=> array(
'foreignKey' => 'program_id'
),
'ProgramVerificationWorksheet'=> array(
'foreignKey' => 'program_id'
)
);
}
?>
这可能是您所谈论的内容。
// Get all the data corrosponding to the secondary customer
$secondaryRow = $this->Customer->find('all', array(
'conditions' => array("Customer.customer_id" => $secondary),
'contain' => array(
'CustomerPersonalInformation',
'CustomerContactInformation',
'CustomerMarketingOption',
'ProgramApplication' => array(
'ProgramCurrentResidence',
'ProgramPreviousResidence',
'ProgramCurrentEmployment',
'ProgramPreviousEmployment',
'ProgramIncome',
'ProgramAdditionalInformation',
'ProgramDoublePreviousEmployment',
'ProgramDoublePreviousResidence',
'ProgramExpense',
'ProgramVerificationWorksheet'
),
'CustomerInteraction'
),
));
我知道该表包含已使用的每个字段,但由于某种原因,它会继续吐出此错误?我假设它是模型,但我可能错了。
最佳答案
似乎您正在对ProgramApplication进行查找,而ProgramApplication中的模型与ProgramCurrentResidence没有关系。您可能需要向ProgramApplication模型中添加一个hasOne或hasMany of ProgramCurrentResidence。