本文整理汇总了PHP中app\models\Person::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::tableName方法的具体用法?PHP Person::tableName怎么用?PHP Person::tableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Person
的用法示例。
在下文中一共展示了Person::tableName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: savePersons
/**
* Сохраняем участников или консультантов
*
* @param $data array
* @param $nType integer
*/
public function savePersons($data, $nType)
{
$bOk = true;
Person::updateAll(['prs_active' => 0, 'prs_type' => 0, 'prs_sec_id' => 0, 'prs_doc_id' => 0], ['prs_doc_id' => $this->doc_id, 'prs_type' => $nType]);
foreach ($data as $ob) {
$ob['prs_type'] = $nType;
$ob['prs_doc_id'] = $this->doc_id;
$ob['prs_active'] = Person::PERSON_STATE_ACTIVE;
$ob['prs_sec_id'] = $this->doc_sec_id;
// Yii::info('consultant = ' . print_r($ob, true));
$s = 'Update ' . Person::tableName() . ' Set ';
$param = [];
$sDelim = '';
if (empty($ob['prs_org']) && !empty($ob['prs_hischool'])) {
$ob['prs_org'] = $ob['prs_hischool'];
}
foreach ($ob as $k => $v) {
$s .= $sDelim . $k . ' = ' . ':' . $k;
$param[':' . $k] = $v;
$sDelim = ', ';
}
$s .= ' Where prs_active = 0 And prs_type = 0 And prs_sec_id = 0 And prs_doc_id = 0 Limit 1';
// Yii::info($s);
$n = Yii::$app->db->createCommand($s, $param)->execute();
if ($n == 0) {
$oNew = new Person();
$oNew->prs_type = $nType;
$aTmp = $oNew->scenarios();
$oNew->attributes = $ob;
$oNew->prs_doc_id = $this->doc_id;
$oNew->prs_active = Person::PERSON_STATE_ACTIVE;
$oNew->prs_sec_id = $this->doc_sec_id;
if (!$oNew->save()) {
$bOk = false;
Yii::info('savePersons() nType = ' . $nType . ' attributes: ' . print_r($oNew->attributes, true));
Yii::info('savePersons() nType = ' . $nType . ' Error save oNew: ' . print_r($oNew->getErrors(), true));
}
}
}
return $bOk;
}
示例2: actionCreate
/**
* Creates a new Person model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Person();
$jobModel = new Job();
if ($jobModel->load(Yii::$app->request->post()) && $jobModel->validate() && $model->load(Yii::$app->request->post()) && $model->validate()) {
$transaction = $model->getDb()->beginTransaction();
try {
if (is_numeric($jobModel->name)) {
$jobModel = $jobModel->findOne($jobModel->name);
} else {
$jobModel = new Job();
$jobModel->load(Yii::$app->request->post());
if (!$jobModel->save(false)) {
throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($jobModel->tableName())), 'msj' => print_r($jobModel->getErrors(), true)]), 500);
}
}
$model->job_id = $jobModel->id;
if (!$model->save(false)) {
throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($model->tableName())), 'msj' => print_r($model->getErrors(), true)]), 500);
}
$transaction->commit();
} catch (\Exception $e) {
$transaction->rollBack();
throw $e;
}
return $this->redirect(['index']);
} else {
return $this->render('create', ['model' => $model, 'jobModel' => $jobModel]);
}
}