Model_customersmt.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Model_Customersmt extends Lin_Model
  3. {
  4. function __construct(){
  5. parent::__construct();
  6. $this->load->database();
  7. $this->table = 'customersmt';
  8. $this->load_table('customersmt');
  9. }
  10. /** 通过名称查找 */
  11. public function get_name($name)
  12. {
  13. return $this->find("name = '$name'");
  14. }
  15. public function get_fullname($fullname)
  16. {
  17. return $this->find("fullname = '$fullname'");
  18. }
  19. public function get_userid($userid)
  20. {
  21. return $this->find("userid = '$userid'");
  22. }
  23. public function get_khcx($userid,$shop)
  24. {
  25. return $this->find("userid = '$userid' and shop = '$shop'");
  26. }
  27. public function get_us($userid,$shop)
  28. {
  29. return $this->find("userid = '$userid' and shop = '$shop'");
  30. }
  31. public function get_data($name,$email,$address)
  32. {
  33. return $this->find("name = '$name' or email = '$email' or address = '$address'");
  34. }
  35. public function get_shopdata($shop,$name,$address)
  36. {
  37. return $this->find("shop = '$shop' and (name = '$name' or address = '$address')");
  38. }
  39. public function get_email($email,$shop)
  40. {
  41. return $this->find("email = '$email' and shop = '$shop'");
  42. }
  43. public function get_address($address)
  44. {
  45. return $this->find("address = '$address'");
  46. }
  47. public function get_excel($titledata,$filename)
  48. {
  49. require_once "./data/excel/PHPExcel/IOFactory.php";
  50. $objPHPExcel = new \PHPExcel();
  51. $objPHPExcel->setActiveSheetIndex(0);
  52. $dataArray = $titledata;
  53. $objPHPExcel->getActiveSheet()->fromArray($dataArray, null, 'A1');
  54. header('Content-Type: application/vnd.ms-excel');
  55. header('Content-Disposition: attachment;filename='.$filename);
  56. $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  57. $objWriter->save('php://output');
  58. $objPHPExcel->disconnectWorksheets();
  59. }
  60. } //end class