public function executeBd(sfWebRequest $request) { for ($x = 855; $x <= 886; $x++) { $respuesta = new Respuestas(); $respuesta->setPreguntasId($x); $respuesta->setOpcionesId(55); $respuesta->setEstadosId(1); $respuesta->save(); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Respuestas(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Respuestas'])) { $model->attributes = $_POST['Respuestas']; if ($model->save()) { $this->redirect(array('create')); } } $this->render('create', array('model' => $model)); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aRespuestas !== null) { if ($this->aRespuestas->isModified() || $this->aRespuestas->isNew()) { $affectedRows += $this->aRespuestas->save($con); } $this->setRespuestas($this->aRespuestas); } if ($this->aEscalas !== null) { if ($this->aEscalas->isModified() || $this->aEscalas->isNew()) { $affectedRows += $this->aEscalas->save($con); } $this->setEscalas($this->aEscalas); } if ($this->isNew()) { $this->modifiedColumns[] = RespuestasescalasPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = RespuestasescalasPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += RespuestasescalasPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
public function postResponse() { $input = Input::all(); $rules = array('id' => 'required|numeric', 'respuesta' => 'required', 'pub_id' => 'required|numeric'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Response::json(array('type' => 'danger', 'msg' => 'Debe enviar un mensaje.')); } $com = Comentarios::find($input['id']); if ($com->respondido == 1) { return Response::json(array('type' => 'danger', 'msg' => 'El comantario ya fue respondido.')); } if ($com->deleted == 1) { $com->deleted = 0; } $resp = new Respuestas(); $resp->comentario_id = $input['id']; $resp->respuesta = $input['respuesta']; $resp->pub_id = $input['pub_id']; $resp->user_id = $com->user_id; $resp->created_at = date('Y-m-d', time()); $resp->updated_at = date('Y-m-d', time()); $user = User::find($resp->user_id); $to_Email = $user->email; $subject = "han respondido tu comentario"; $data = array('email' => $to_Email); Mail::send('emails.respuesta', $data, function ($message) use($to_Email, $subject) { $message->to($to_Email)->from('*****@*****.**')->subject($subject); }); if ($resp->save()) { $com->respondido = 1; $com->save(); $msg = "Han respondido tu comentario: " . $com->comentario; $data = array('message' => $msg, 'title' => $msg, 'msgcnt' => null, 'timeToLive' => 3000); /*$gcm = GcmDevices::where('usuario','=',$user->username)->orderBy('id','DESC')->get(array('gcm_regid')); $regId = array(); $i = 0; foreach($gcm as $g) { $regId[$i] = $g['gcm_regid']; $i++; } $doGcm = new Gcm; $response = $doGcm->send_notification($regId,$data);*/ return Response::json(array('type' => 'success', 'msg' => 'Respuesta guardada satisfactoriamente')); } else { return Response::json(array('type' => 'danger', 'msg' => 'Error al guardar la respuesta')); } return Response::json($input); }
public function postResponse() { $id = Input::get('id'); $input = Input::all(); $rules = array('comment_id' => 'required|numeric', 'respuesta' => 'required', 'pub_id' => 'required|numeric'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Response::json(array('type' => 'danger', 'msg' => 'Error al validar los datos.', 'data' => $validator->getMessageBag()->toArray())); } $com = Comentarios::find($input['comment_id']); if ($com->respondido == 1) { return Response::json(array('type' => 'danger', 'msg' => 'El comantario ya fue respondido.')); } if ($com->deleted == 1) { $com->deleted = 0; } $resp = new Respuestas(); $resp->comentario_id = $input['comment_id']; $resp->respuesta = $input['respuesta']; $resp->pub_id = $input['pub_id']; $resp->user_id = $com->user_id; $resp->created_at = date('Y-m-d', time()); $resp->updated_at = date('Y-m-d', time()); $user = User::find($resp->user_id); $to_Email = $user->email; $subject = "han respondido tu comentario"; $data = array('email' => $to_Email); Mail::send('emails.respuesta', $data, function ($message) use($to_Email, $subject) { $message->to($to_Email)->from('*****@*****.**')->subject($subject); }); if ($resp->save()) { $com->respondido = 1; $com->save(); return Response::json(array('type' => 'success', 'msg' => 'Respuesta guardada satisfactoriamente')); } else { return Response::json(array('type' => 'danger', 'msg' => 'Error al guardar la respuesta')); } return Response::json($input); }