Model_customerOLD.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Model_Customer2 extends Lin_Model
  3. {
  4. function __construct(){
  5. parent::__construct();
  6. $this->load->database();
  7. $this->table = 'customer2';
  8. $this->load_table('customer2');
  9. }
  10. /** 通过名称查找 */
  11. public function get_name($name)
  12. {
  13. return $this->find("name = '$name'");
  14. }
  15. public function get_data($name,$email,$address)
  16. {
  17. return $this->find("name = '$name' or email = '$email' or address = '$address'");
  18. }
  19. public function get_email($email)
  20. {
  21. return $this->find("email = '$email'");
  22. }
  23. public function get_address($address)
  24. {
  25. return $this->find("address = '$address'");
  26. }
  27. public function get_excel($titledata,$filename)
  28. {
  29. require_once "./data/excel/PHPExcel/IOFactory.php";
  30. $objPHPExcel = new \PHPExcel();
  31. $objPHPExcel->setActiveSheetIndex(0);
  32. $dataArray = $titledata;
  33. $objPHPExcel->getActiveSheet()->fromArray($dataArray, null, 'A1');
  34. header('Content-Type: application/vnd.ms-excel');
  35. header('Content-Disposition: attachment;filename='.$filename);
  36. $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  37. $objWriter->save('php://output');
  38. $objPHPExcel->disconnectWorksheets();
  39. }
  40. } //end class