VM暫存
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

61 wiersze
1.6KB

  1. <?php
  2. /*
  3. file: Landb_model.php 撈區網資料庫
  4. */
  5. class Landb_model extends CI_Model
  6. {
  7. function __construct()
  8. {
  9. parent::__construct();
  10. // 資料庫連線
  11. //$dsn_old_db = 'mysqli://root:HISHARP@192.168.0.2:3306/parking';
  12. //$this->dsn_old_db = $this->load->database($dsn_old_db, true);
  13. $this->now_str = date('Y-m-d H:i:s');
  14. }
  15. // test
  16. public function test($lpr)
  17. {
  18. $result = $lpr.' @ '. $this->now_str.' @ ';
  19. $sql = "SELECT ParkingNum as pksno, LPR as lpr
  20. FROM table_carpark where lpr = 'xxx'";
  21. $dsn_old_db = $this->load->database('old_db', true);
  22. /*
  23. $config['hostname'] = '192.168.0.2';
  24. $config['port'] = "3306";
  25. $config['username'] = 'root';
  26. $config['password'] = 'HISHARP';
  27. $config['database'] = 'parking';
  28. $config['dbdriver'] = 'mysqli';
  29. $config['dbprefix'] = '';
  30. $config['pconnect'] = FALSE;
  31. $config['db_debug'] = TRUE;
  32. $config['cache_on'] = FALSE;
  33. $config['cachedir'] = '';
  34. $config['char_set'] = 'utf8';
  35. $config['dbcollat'] = 'utf8_general_ci';
  36. $dsn_old_db = $this->load->database($config, true);
  37. */
  38. $retults = $dsn_old_db->query($sql)->result_array();
  39. //$retults = $this->dsn_old_db->query($sql)->result_array();
  40. $seat_no = '';
  41. if(!empty($retults[0]))
  42. {
  43. $seat_no = '-'.substr($retults[0]['pksno'], 0, 1).'_'.substr($retults[0]['pksno'], 1);
  44. }
  45. return
  46. 'result >>>>>' . $result . '@' . '<br/>'.
  47. $sql . '<br/>'.
  48. json_encode($retults, true).'<br/>'.
  49. $seat_no;
  50. }
  51. }