Commit ce83a19c authored by nuxer's avatar nuxer

LVS, PHP DBMS read/write Function 추가

parent 68af588f
Pipeline #5097 passed with stages
in 3 seconds
......@@ -116,3 +116,104 @@ TCP 180.180.180.143:3306 wrr
![source_overview](./images/lvs-elk.png)
## PHP DBMS Connection Function
```php
<?php
//readonly 연결 함수 선언
function read_db(){
$host = "180.180.180.143";
$user = "유저아이디";
$pass = "패스워드";
$database = "디비명";
$connect = mysql_connect($host, $user, $pass) or die("ERROR!");
mysql_query("SET NAMES 'utf8'");
mysql_select_db($database, $connect);
return $connect;
}
//read/write 연결 함수 선언
function write_db(){
$host = "180.180.180.250";
$user = "유저아이디";
$pass = "패스워드";
$database = "디비명";
$connect = mysql_connect($host, $user, $pass) or die("ERROR!");
mysql_query("SET NAMES 'utf8'");
mysql_select_db($database, $connect);
return $connect;
}
?>
```
## PHP DBMS Connection Function
```php
<?php
//readonly 연결 함수 선언
function read_db(){
$host = "180.180.180.143";
$user = "유저아이디";
$pass = "패스워드";
$database = "디비명";
$connect = mysqli_connect($host, $user, $pass, $database);
if (!$connect) {
$error = mysqli_connect_error();
$errno = mysqli_connect_errno();
exit;
}else{
mysqli_select_db($connect, $database);
}
return $connect;
}
//read/write 연결 함수 선언
function write_db(){
$host = "180.180.180.250";
$user = "유저아이디";
$pass = "패스워드";
$database = "디비명";
$connect = mysqli_connect($host, $user, $pass, $database);
if (!$connect) {
$error = mysqli_connect_error();
$errno = mysqli_connect_errno();
exit;
}else{
mysqli_select_db($connect, $database);
}
return $connect;
}
?>
```
## PHP Call Pages Usage Example
- Read Only
```php
<?php
$query = "SELECT ~";
$result = mysqli_query(read_db(), $query);
?>
```
- Read/Write
```php
<?php
$query = "INSERT/UPDATE/DELETE ~";
$result = mysqli_query(write_db(), $query);
?>
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment