PHP connects to mysql, mssql, oracle
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 09:06:44
Original
1316 people have browsed it
PHP connects to mysql, mssql, oracle
- dbtypedef.php
- // Database partial parameter settings
- @define("DATABASE_ACCESS", 0);
- @define("DATABASE_MSSQL", 1);
- @define("DATABASE_ORACLE", 2 );
- @define("DATABASE_MYSQL", 3);
- @define("DATABASE_POSTGRESQL",4);
- @define("DATABASE_SQLITE", 5);
- ?>
-
- /*======= ================================================== =====*/
- /* File name: Model.class.php
- /* Summary: Common parent class model for data access layer database processing). */
- /* Author:
- /* Creation time: 2010- 10-20
- /*============================================== ==================*/
- class Model {
- protected $mysqli; //
- protected $messList; //Prompt message list
- protected $tabName; //Data table
- protected $fieldList; //Data list
- protected $oracle; //Data list
-
- public function __construct() {
-
- if(DB_TYPE == DATABASE_MYSQL)
- {
- $this->mysqli = new mysqli ( DB_HOST, DB_USER, DB_PWD, DB_NAME );
- $this->mysqli->query("set names utf8");
- if (mysqli_connect_errno ()) {
- echo "" . mysqli_connect_error ();
- $this->mysqli = FALSE;
- exit();
- }
- }
- else if(DB_TYPE == DATABASE_MSSQL)
- {
- $conn=mssql_connect(DB_HOST, DB_USER, DB_PWD)or die("Couldn't connect to SQL Server on ".DB_HOST ."");
- mssql_select_db(DB_NAME,$conn);
- mssql_query("set names utf8");
- }
- else if(DB_TYPE == DATABASE_ORACLE)
- {
- $ora_connstr = "(description=(address=(protocol =tcp) (host=".DB_HOST.")(port=".DB_PORT.")) (connect_data=(service_name=".DB_NAME.")))";
- $this->oracle = oci_connect(DB_USER, DB_PWD,$ora_connstr);
- if (!$this->oracle) {
- echo "oracle connection failed";
- $e = oci_error();
- trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
- }
- }
- }
- }
Copy code
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11