PHP Connection Mysql,mssql,oracle

Source: Internet
Author: User
Tags mssql
PHP Connection Mysql,mssql,oracle
  1. dbtypedef.php
  2. Database part parameter settings
  3. @define ("Database_access", 0);
  4. @define ("Database_mssql", 1);
  5. @define ("Database_oracle", 2);
  6. @define ("Database_mysql", 3);
  7. @define ("Database_postgresql", 4);
  8. @define ("Database_sqlite", 5);
  9. ?>
  10. /*==============================================================*/
  11. /* File name: Model.class.php
  12. /* Summary: The public parent class model that the data access layer database processes. */
  13. /* Author:
  14. /* Created on: 2010-10-20
  15. /*==============================================================*/
  16. Class Model {
  17. protected $mysqli; //
  18. protected $messList; List of prompt information
  19. protected $tabName; Data Sheet
  20. protected $fieldList; Data list
  21. protected $oracle; Data list
  22. Public Function __construct () {
  23. if (Db_type = = Database_mysql)
  24. {
  25. $this->mysqli = new Mysqli (Db_host, Db_user, Db_pwd, db_name);
  26. $this->mysqli->query ("Set names UTF8");
  27. if (Mysqli_connect_errno ()) {
  28. echo "". Mysqli_connect_error ();
  29. $this->mysqli = FALSE;
  30. Exit ();
  31. }
  32. }
  33. else if (Db_type = = Database_mssql)
  34. {
  35. $conn =mssql_connect (Db_host, Db_user, db_pwd) or Die ("couldn ' t connect to SQL Server on". Db_host. "");
  36. mssql_select_db (db_name, $conn);
  37. Mssql_query ("Set names UTF8");
  38. }
  39. else if (Db_type = = database_oracle)
  40. {
  41. $ora _connstr = "(Description= (address= (protocol=tcp) (host=). Db_host. ") (port= ". Db_port. ")) (Connect_data= (service_name= ". Db_name. ")))";
  42. $this->oracle = Oci_connect (Db_user, db_pwd, $ora _connstr);
  43. if (! $this->oracle) {
  44. echo "Oracle connection Failed";
  45. $e = Oci_error ();
  46. Trigger_error (Htmlentities ($e [' message '], ent_quotes), e_user_error);
  47. }
  48. }
  49. }
  50. }
Copy Code
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.