本文整理汇总了PHP中Card::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::save方法的具体用法?PHP Card::save怎么用?PHP Card::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_card
public function edit_card($card_id = 0, $type_id = 1, $deck_id = 1, $repeating = 0)
{
if ($repeating == 1) {
$this->data['error'] = "New Card Added.";
}
$card = new Card($card_id);
$card->type_id = $type_id;
$card->deck_id = $deck_id;
if ($_POST) {
$repeat = FALSE;
if ($card_id == 0) {
$repeat = TRUE;
}
foreach ($this->input->post() as $key => $val) {
$card->{$key} = nl2br($val);
}
$card->save();
if ($repeat) {
redirect('/admin/cards/edit_card/0/' . $type_id . '/' . $deck_id . '/1');
}
}
$this->data['card'] = $card;
$this->data['current_function_view'] = $this->load->view('admin/cards/edit_card', $this->data, true);
$this->load->view('admin/master', $this->data);
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$card = new Card();
$card->fill(Input::all());
$card->save();
return Response::json(array('success' => true));
}
示例3: generate
public function generate()
{
$serial = new Serial();
$serial->serial = $this->serial;
$serial->duration = $this->duration;
$serial->save();
for ($number = 1; $number <= $this->quantity; $number++) {
$card = new Card();
$card->serial_id = $serial->id;
$card->number = $number;
$card->save();
}
}
示例4: updateCard
public function updateCard(Card $card)
{
$inputs = ['color' => Input::get('color'), 'content' => Input::get('content'), 'comment' => Input::get('comment'), 'worker_id' => Input::get('worker_id')];
$valid = Validator::make($inputs, Card::$rules);
if ($valid->passes()) {
$card->color = $inputs['color'];
$card->content = $inputs['content'];
$card->comment = $inputs['comment'];
$card->worker_id = $inputs['worker_id'];
$card->save();
return Redirect::route('card.list')->with('success', Lang::choice('messages.Cards', 1) . ' ' . trans('is updated'));
} else {
return Redirect::back()->withErrors($valid)->withInput();
}
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
if (Yii::app()->user->checkAccess('addCard')) {
$model = new Card();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$model->owner_id = Yii::app()->user->id;
if (isset($_POST['Card'])) {
$model->attributes = $_POST['Card'];
//$model->office=$_POST['office'];
//$model->department=$_POST['department'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
/*$office=new Office;
$department=new Department;
$model->save();*/
$this->render('create', array('model' => $model));
} else {
throw new CHttpException(403, 'You are not allowed to perform this action.');
}
}
示例6: function
$app->get('/add_player_two_cards', function () use($app) {
return $app['twig']->render('add_player_two_cards.html.twig');
});
$app->post('/player_two_hand', function () use($app) {
$active_game = Game::getAll();
$active_players = Player::getAll();
$cardOne = new Card(rand(1, 10), firstcard);
$cardOne->save();
$cardTwo = new Card(rand(1, 10), secondcard);
$cardTwo->save();
$cardThree = new Card(rand(1, 10), thirdcard);
$cardThree->save();
$cardFour = new Card(rand(1, 10), fourthcard);
$cardFour->save();
$cardFive = new Card(rand(1, 10), fifthcard);
$cardFive->save();
$current_players = $active_players[0]->getPlayers();
$current_score = $active_players[0]->setScore2(0);
$current_score = $active_players[0]->getScore2();
$current_hand = array();
$draw = array();
for ($i = 0; $i <= 4; $i++) {
array_push($current_hand, rand(1, 2));
}
for ($z = 0; $z <= 4; $z++) {
if ($current_hand[0] == $current_hand[1] && $current_hand[0] == $current_hand[2] && $current_hand[0] == $current_hand[3]) {
$active_players[0]->setScore2($current_score + 1);
}
}
// var_dump($current_hand);
for ($x = 0; $x <= 4; $x++) {
示例7: doSave
/**
* 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->aRoomprofile !== null) {
if ($this->aRoomprofile->isModified() || $this->aRoomprofile->isNew()) {
$affectedRows += $this->aRoomprofile->save($con);
}
$this->setRoomprofile($this->aRoomprofile);
}
if ($this->aActivity !== null) {
if ($this->aActivity->isModified() || $this->aActivity->isNew()) {
$affectedRows += $this->aActivity->save($con);
}
$this->setActivity($this->aActivity);
}
if ($this->aReservationreason !== null) {
if ($this->aReservationreason->isModified() || $this->aReservationreason->isNew()) {
$affectedRows += $this->aReservationreason->save($con);
}
$this->setReservationreason($this->aReservationreason);
}
if ($this->aUsergroup !== null) {
if ($this->aUsergroup->isModified() || $this->aUsergroup->isNew()) {
$affectedRows += $this->aUsergroup->save($con);
}
$this->setUsergroup($this->aUsergroup);
}
if ($this->aCard !== null) {
if ($this->aCard->isModified() || $this->aCard->isNew()) {
$affectedRows += $this->aCard->save($con);
}
$this->setCard($this->aCard);
}
if ($this->aUser !== null) {
if ($this->aUser->isModified() || $this->aUser->isNew()) {
$affectedRows += $this->aUser->save($con);
}
$this->setUser($this->aUser);
}
if ($this->aReservationRelatedByReservationparentId !== null) {
if ($this->aReservationRelatedByReservationparentId->isModified() || $this->aReservationRelatedByReservationparentId->isNew()) {
$affectedRows += $this->aReservationRelatedByReservationparentId->save($con);
}
$this->setReservationRelatedByReservationparentId($this->aReservationRelatedByReservationparentId);
}
if ($this->isNew()) {
$this->modifiedColumns[] = ReservationPeer::ID;
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = ReservationPeer::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 += ReservationPeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
if ($this->collReservationsRelatedByReservationparentId !== null) {
foreach ($this->collReservationsRelatedByReservationparentId as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->collReservationOtherMemberss !== null) {
foreach ($this->collReservationOtherMemberss as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
//.........这里部分代码省略.........
示例8: addAction
public function addAction()
{
//var_dump(Input::all());
if (Input::server("REQUEST_METHOD") == "POST") {
try {
$action = "insert";
$id = Input::get('id');
//$school = Input::get('school');
$course = Input::get('course');
$name = Input::get('name');
$description = Input::get('description');
$fluency = Input::get('fluency');
$publish = Input::get('publish');
$cards_id = Input::get('card_ids');
$f_text = Input::get('f_text');
$f_cardtype = Input::get('cardtype');
$f_text_option = Input::get('f_text_option');
$f_sound = Input::get('f_sound');
$f_image = Input::get('f_image');
if (isset($id) && !empty($id)) {
$sprint = Sprint::find($id);
$action = "update";
$cards = DB::table('cards')->where('sprint', $id)->get();
foreach ($cards as $card) {
$flag = false;
for ($i = 0; $i < sizeof($cards_id); $i++) {
if ($card->id == $cards_id[$i]) {
$flag = true;
}
}
if (!$flag) {
DB::table('cards')->where('id', $card->id)->delete();
}
}
} else {
$sprint = new Sprint();
}
//$sprint->school = $school;
$sprint->course = $course;
$sprint->name = $name;
$sprint->description = $description;
$sprint->fluency_rate = $fluency;
$sprint->published = $publish;
$sprint->save();
if ($action == "insert") {
$sprint_id = DB::getPdo()->lastInsertId();
} else {
$sprint_id = $id;
}
$cards = "";
for ($i = 0; $i < count($f_text); $i++) {
$idx = $i + 1;
$card_type = $f_cardtype[$i];
$cardid = $cards_id[$i];
if ($action == "update" && $cardid > 0) {
$card = Card::find($cardid);
} else {
$card = new Card();
}
$card->sprint = $sprint_id;
$card->card_type = $card_type;
$card->f_text = $f_text[$i];
if (!empty($f_text_option[$i])) {
$card->f_text_option = $f_text_option[$i];
} else {
$card->f_text_option = 0;
}
if (!empty($f_sound[$i])) {
$f_sound_path = "";
$f_sound_file = "";
if ($f_sound[$i] == "none") {
$card->f_sound_option = 0;
} else {
$card->f_sound_option = 1;
$f_sound_pos = strripos($f_sound[$i], "/");
$f_sound_path = substr($f_sound[$i], 0, $f_sound_pos + 1);
$f_sound_file = substr($f_sound[$i], $f_sound_pos + 1);
}
$card->f_sound = $f_sound_file;
$card->f_sound_path = $f_sound_path;
} else {
if ($f_sound[$i] == "none") {
$card->f_sound_option = 0;
} else {
$card->f_sound_option = 1;
}
$card->f_sound = "";
$card->f_sound_path = "";
}
if (!empty($f_image[$i])) {
$f_image_file = "";
$f_image_path = "";
if ($f_image[$i] == "none") {
$card->f_image_option = 0;
} else {
$card->f_image_option = 0;
$f_image_pos = strripos($f_image[$i], "/");
$f_image_path = substr($f_image[$i], 0, $f_image_pos + 1);
$f_image_file = substr($f_image[$i], $f_image_pos + 1);
}
//.........这里部分代码省略.........
开发者ID:AxelPardemann,项目名称:E-Learning-System-based-on-Laravel-and-Bootstrap,代码行数:101,代码来源:SprintController.php
示例9: explode
}
if (!move_uploaded_file($_FILES['NewLogo']['tmp_name'], DIR_LOGOS . $filename)) {
$errors[] = $Lang['Errors']['move_upload_error'];
} else {
//Sets logo filename in card data
$card->logo = $filename;
}
break;
#TODO : more explicit error messages
#TODO : more explicit error messages
default:
$errors[] = $Lang['Errors']['other_upload_error'];
}
}
//3. Saves the card
$card->save();
$id = $card->id;
//4. Keywords
//TODO : more clever code
Keywords::Truncate('C', $card->id);
$keywords = explode(', ', $_POST['keywords']);
foreach ($keywords as $keyword) {
Keywords::Add('C', $card->id, $keyword);
}
//Yes, it's absolutely not optimized and very stupid to all delete and add again !
$action = 'view';
} elseif ($_GET['action'] == 'clone') {
//User's cloning a card, so erase base card info
unset($id, $card->id);
}
if ($action == 'view') {
示例10: actionCreateCard
public function actionCreateCard()
{
//$orderNo = substr(md5(time()), 0, 12);
if ($num = intval($_POST['num'])) {
$card_arr = $_POST['Card'];
$type_id = $card_arr['type_id'];
if ($type_id >= 1000) {
$typeid = $type_id;
} else {
if ($type_id < 1000 && $type_id >= 100) {
$typeid = '0' . $type_id;
} else {
if ($type_id < 100 && $type_id >= 10) {
$typeid = '00' . $type_id;
} else {
if ($type_id < 10 && $type_id > 0) {
$typeid = '000' . $type_id;
}
}
}
}
$i = 1;
while ($num >= $i) {
$card_num = 'U' . $typeid . date('ymd') . mt_rand(1000, 9999);
$card_arr['card_num'] = $card_num;
$model = new Card();
$model->attributes = $card_arr;
if ($model->validate() && $model->save()) {
// var_dump($card_num);
$i++;
} else {
var_dump($model->getErrors());
}
}
Yii::app()->user->setFlash('Card', '创建成功');
$this->redirect(array('card/card'));
} else {
Yii::app()->user->setFlash('card', '请输入创建数量');
}
$model = new Card();
$getTypes = CardType::model()->getType();
$this->render('create', ['model' => $model, 'getTypes' => $getTypes]);
}