当前位置: 首页>>代码示例>>PHP>>正文


PHP Version::retrieve_current_version方法代码示例

本文整理汇总了PHP中Version::retrieve_current_version方法的典型用法代码示例。如果您正苦于以下问题:PHP Version::retrieve_current_version方法的具体用法?PHP Version::retrieve_current_version怎么用?PHP Version::retrieve_current_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Version的用法示例。


在下文中一共展示了Version::retrieve_current_version方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: move

 public static function move($type, $id_card, $id_deck)
 {
     $CI = get_instance();
     $CI->load->model('Card');
     $CI->load->model('Version');
     if (Card::card_is_deleted($id_card)) {
         $CI->transaction->set_as_rollback();
         return new Standard_error('MOVE_ERROR', 'The card has been deleted.');
     }
     $CI->db->select('type, id_version')->from('card_deck_version')->where('id_card', $id_card)->where('id_deck', $id_deck)->where('is_last', true);
     $query = $CI->db->get();
     if ($query->num_rows() != 0) {
         $row = $query->row();
     }
     if ($type == 'remove' && ($query->num_rows() == 0 || $row->type == 'remove')) {
         $CI->transaction->set_as_rollback();
         return new Standard_error('MOVE_ERROR', 'The card is not in the deck.');
     }
     if ($type == 'add' && $query->num_rows() != 0 && $row->type == 'add') {
         $CI->transaction->set_as_rollback();
         return new Standard_error('MOVE_ERROR', 'The card is already in the deck.');
     }
     $current_version = Version::retrieve_current_version();
     if ($query->num_rows() == 0 || $row->id_version < $current_version->get_id()) {
         if ($query->num_rows() != 0) {
             if (!self::set_last_move($id_card, $id_deck, false)) {
                 $CI->transaction->set_as_rollback();
                 return new Standard_error();
             }
         }
         $data = array('id_card' => $id_card, 'id_deck' => $id_deck, 'id_version' => $current_version->get_id(), 'type' => $type, 'is_last' => true);
         if ($CI->db->insert('card_deck_version', $data)) {
             return true;
         } else {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
     } else {
         $CI->db->where('id_card', $id_card)->where('id_deck', $id_deck)->where('id_version', $current_version->get_id());
         if (!$CI->db->delete('card_deck_version')) {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
         if (self::set_last_move($id_card, $id_deck, true)) {
             return true;
         } else {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
     }
 }
开发者ID:vmoulin77,项目名称:DVB,代码行数:51,代码来源:Card_move.php

示例2: insert

 public static function insert($num, $name)
 {
     $CI = get_instance();
     $CI->load->model('Version');
     if (!self::num_is_free($num)) {
         $CI->transaction->set_as_rollback();
         return new Standard_error('INSERT_ERROR', "The deck number is not free.");
     }
     $current_version = Version::retrieve_current_version();
     $data = array('num' => $num, 'name' => $name, 'id_version_when_created' => $current_version->get_id());
     if ($CI->db->insert('deck', $data)) {
         return true;
     } else {
         $CI->transaction->set_as_rollback();
         return new Standard_error();
     }
 }
开发者ID:vmoulin77,项目名称:DVB,代码行数:17,代码来源:Deck.php

示例3: delete

 public static function delete($id)
 {
     $CI = get_instance();
     $CI->load->model('Card_move');
     $CI->load->model('Version');
     $CI->load->model('Deck');
     if (self::card_is_deleted($id)) {
         $CI->transaction->set_as_rollback();
         return new Standard_error('DELETE_ERROR', 'The card has already been deleted.');
     }
     if (self::never_versioned($id)) {
         $CI->db->where('id', $id);
         if ($CI->db->delete('card')) {
             return true;
         } else {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
     } else {
         $current_version = Version::retrieve_current_version();
         /********************************************************/
         $CI->db->where('id_card', $id);
         if (!$CI->db->delete('campaign_card')) {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
         /********************************************************/
         /********************************************************/
         $CI->db->select('id_deck')->from('card_deck_version')->where('id_card', $id)->where('id_version', $current_version->get_id())->where('type', 'add');
         $query = $CI->db->get();
         $ids_decks = array();
         foreach ($query->result() as $row) {
             $ids_decks[] = $row->id_deck;
         }
         $CI->db->where('id_card', $id)->where('id_version', $current_version->get_id())->where('type', 'add');
         if (!$CI->db->delete('card_deck_version')) {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
         foreach ($ids_decks as $id_deck) {
             if (!Card_move::set_last_move($id, $id_deck, true)) {
                 $CI->transaction->set_as_rollback();
                 return new Standard_error();
             }
         }
         /********************************************************/
         /********************************************************/
         $finder_manager = new Finder_manager('Deck', 'find_with_contains_current_card', FIND_MANY, ['id_card' => $id]);
         $decks = $finder_manager->get();
         foreach ($decks as $deck) {
             if ($deck->contains_current_card) {
                 if (!Card_move::set_last_move($id, $deck->get_id(), false)) {
                     $CI->transaction->set_as_rollback();
                     return new Standard_error();
                 }
                 $data = array('id_card' => $id, 'id_deck' => $deck->get_id(), 'id_version' => $current_version->get_id(), 'type' => 'remove', 'is_last' => true);
                 if (!$CI->db->insert('card_deck_version', $data)) {
                     $CI->transaction->set_as_rollback();
                     return new Standard_error();
                 }
             }
         }
         /********************************************************/
         $CI->db->where('id_card', $id)->where('id_version', $current_version->get_id());
         if (!$CI->db->delete('card_content')) {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
         $CI->db->select('id')->from('card_content')->where('id_card', $id)->order_by('id_version', 'DESC')->limit(1);
         $query = $CI->db->get();
         if ($query->num_rows() == 0) {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         } else {
             $row = $query->row();
             $CI->db->set(array('is_last' => true))->where('id', $row->id);
             if (!$CI->db->update('card_content')) {
                 $CI->transaction->set_as_rollback();
                 return new Standard_error();
             }
         }
         $data = array('is_deleted' => true, 'id_version_when_deleted' => $current_version->get_id());
         $CI->db->set($data)->where('id', $id);
         if ($CI->db->update('card')) {
             return true;
         } else {
             $CI->transaction->set_as_rollback();
             return new Standard_error();
         }
     }
 }
开发者ID:vmoulin77,项目名称:DVB,代码行数:91,代码来源:Card.php


注:本文中的Version::retrieve_current_version方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。