/** * Test Save Function */ public function testSave() { $sms = new SMS(); $token = $sms->get_auth_token(); $date = date('Y-m-d H:i:s'); $sms->save('00001111', '1', '2', 'testing', $date, $token); $resultingTable = $this->getConnection()->createQueryTable("mo", "SELECT msisdn,operatorid,shortcodeid,text FROM mo WHERE msisdn = '00001111' and text = 'testing' LIMIT 1"); $expectedTable = $this->createXmlDataSet("expected_data.xml")->getTable("mo"); $this->assertTablesEqual($expectedTable, $resultingTable); echo 'Test 2: (Saving to Database): {"status": "ok"}' . PHP_EOL; }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $rules = ['type' => 'required', 'sender' => 'required|max:100', 'message' => 'required']; $validator = \Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('/sms')->withErrors($validator); } else { $sms = new SMS(); $sms->type = Input::get('type'); $sms->sender = Input::get('sender'); $sms->message = Input::get('message'); $sms->save(); return Redirect::to('/sms')->with("success", "SMS Format Created Succesfully."); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new SMS(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['SMS'])) { $model->attributes = $_POST['SMS']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
<?php require_once 'functions.php'; $sms = new SMS(); $token = $sms->get_auth_token(); $sms->save($_REQUEST['msisdn'], $_REQUEST['operatorid'], $_REQUEST['shortcodeid'], $_REQUEST['text'], null, $token);