TransportModel.class.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Model;
  15. use Think\Model;
  16. class TransportModel extends Model{
  17. public function getExtendInfo($condition){
  18. return M('transport_extend')->where($condition)->select();
  19. }
  20. public function delTansport($condition){
  21. try {
  22. $this->startTrans();
  23. $delete = M('transport')->where($condition)->delete();
  24. if ($delete) {
  25. $delete = M('transport_extend')->where(array('transport_id'=>$condition['id']))->delete();
  26. }
  27. if (!$delete) throw new Exception();
  28. $this->commit();
  29. }catch (Exception $e){
  30. $model->rollback();
  31. return false;
  32. }
  33. return true;
  34. }
  35. public function getTransportInfo($condition){
  36. return M('transport')->where($condition)->find();
  37. }
  38. public function getTransportList(){
  39. $count=M('transport')->count();
  40. $Page = new \Think\Page($count,4);
  41. $show = $Page->show();// 分页显示输出
  42. $list= M('transport')->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
  43. return array(
  44. 'list'=>$list,
  45. 'page'=>$show
  46. );
  47. }
  48. public function getExtendList($condition=array(), $order='is_default'){
  49. return M('transport_extend')->where($condition)->order($order)->select();
  50. }
  51. public function transUpdate($data){
  52. return M('transport')->save($data);
  53. }
  54. public function delExtend($transport_id){
  55. return M('transport_extend')->where(array('transport_id'=>$transport_id))->delete();
  56. }
  57. public function addTransport($data){
  58. return M('transport')->add($data);
  59. }
  60. public function addExtend($data){
  61. return M('transport_extend')->addAll($data);
  62. }
  63. }