/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Documento::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'fecha_creacion' => $this->fecha_creacion, 'id_persona' => $this->id_persona]); $query->andFilterWhere(['like', 'nombre_documento', $this->nombre_documento])->andFilterWhere(['like', 'direccion_archivo', $this->direccion_archivo]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Documento::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['iddocumento' => $this->iddocumento, 'candidato_idcandidato' => $this->candidato_idcandidato]); $query->andFilterWhere(['like', 'tipo_documento', $this->tipo_documento])->andFilterWhere(['like', 'numero_documento', $this->numero_documento])->andFilterWhere(['like', 'link_documento', $this->link_documento]); return $dataProvider; }
/** * Deletes an existing Documento model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $tiempo_de_inicio = microtime(true); $documento = Documento::find()->where(['id_persona' => $id])->all(); foreach ($documento as $i => $doc) { $doc->delete(); } // Documento::deleteAll(['id_persona'=>$id]);//<----es mas rapido $tiempo_fin = microtime(true); $mensaje = "Tiempo empleado para eliminar: " . ($tiempo_fin - $tiempo_de_inicio); //find()->where(['id_persona' =$id]); //$this->findModel($id)->delete(); return $this->redirect(['index', 'mensaje' => $mensaje]); }
<?php use yii\helpers\Html; use yii\grid\GridView; use yii\helpers\Url; use backend\models\Documento; /* @var $this yii\web\View */ /* @var $model backend\models\Candidato */ $this->title = 'Update Candidato: ' . ' ' . $model->idcandidato; $this->params['breadcrumbs'][] = ['label' => 'Candidatos', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->idcandidato, 'url' => ['view', 'id' => $model->idcandidato]]; $this->params['breadcrumbs'][] = 'Update'; $modelDoc = Documento::find()->where(['candidato_idcandidato' => $model->idcandidato])->one(); ?> <div class="candidato-update"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo $this->render('_form', ['model' => $model]); ?> <p> <?php echo Html::a('Criar Documento', ['/documento/create', 'idcandidato' => $model->idcandidato], ['class' => 'btn btn-success']); ?> </p>