public function actionDeleteAll() { $tiempo_inicio = microtime(true); $model = Persona::find()->all(); foreach ($model as $i => $persona) { $persona->delete(); } $tiempo_fin = microtime(true); $mensaje = 'Tiempo empleado para eliminar ' . count($model) . ' tuplas: ' . ($tiempo_fin - $tiempo_inicio); $this->redirect(['index', 'mensaje' => $mensaje]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Persona::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(['id' => $this->id]); $query->andFilterWhere(['like', 'nombre_completo', $this->nombre_completo])->andFilterWhere(['like', 'pais', $this->pais])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Persona::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(['id' => $this->id, 'municipio_id' => $this->municipio_id, 'tipo_identificacion_id' => $this->tipo_identificacion_id]); $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'apellido', $this->apellido])->andFilterWhere(['like', 'identificacion', $this->identificacion])->andFilterWhere(['like', 'direccion', $this->direccion])->andFilterWhere(['like', 'telefono', $this->telefono]); return $dataProvider; }
public function buscarPorNombre($nombre) { return Persona::find()->where(['like', 'nombre_completo', $nombre]); }