Model_customersmt2.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Model_Customersmt2 extends Lin_Model
  3. {
  4. function __construct(){
  5. parent::__construct();
  6. $this->load->database();
  7. $this->table = 'customersmt2';
  8. $this->load_table('customersmt2');
  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_us($userid,$shop)
  24. {
  25. return $this->find("userid = '$userid' and shop = '$shop'");
  26. }
  27. public function get_data($name,$email,$address)
  28. {
  29. return $this->find("name = '$name' or email = '$email' or address = '$address'");
  30. }
  31. public function get_shopdata($shop,$name,$address)
  32. {
  33. return $this->find("shop = '$shop' and (name = '$name' or address = '$address')");
  34. }
  35. public function get_email($email,$shop)
  36. {
  37. return $this->find("email = '$email' and shop = '$shop'");
  38. }
  39. public function get_address($address)
  40. {
  41. return $this->find("address = '$address'");
  42. }
  43. public function get_excel($titledata,$filename)
  44. {
  45. require_once "./data/excel/PHPExcel/IOFactory.php";
  46. $objPHPExcel = new \PHPExcel();
  47. $objPHPExcel->setActiveSheetIndex(0);
  48. $dataArray = $titledata;
  49. $objPHPExcel->getActiveSheet()->fromArray($dataArray, null, 'A1');
  50. header('Content-Type: application/vnd.ms-excel');
  51. header('Content-Disposition: attachment;filename='.$filename);
  52. $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  53. $objWriter->save('php://output');
  54. $objPHPExcel->disconnectWorksheets();
  55. }
  56. } //end class