reasonableframework/helper/database.mysql.old.php

60 lines
1.3 KiB
PHP
Raw Normal View History

2018-09-13 15:56:12 +00:00
<?php
/**
* @file database.mysql.old.php
* @date 2018-09-14
* @author Go Namhyeon <gnh1201@gmail.com>
* @brief MySQL-old (lower than 5.4) database helper
*/
2019-02-26 05:40:03 +00:00
if(!check_function_exists("get_db_mysql_old_connect")) {
2018-09-13 15:56:12 +00:00
function get_db_mysql_old_connect() {
$conn = false;
$config = get_config();
2018-09-13 15:57:03 +00:00
$conn = @mysql_connect($config['db_host'], $config['db_username'], $config['db_password']);
if(!$conn) {
set_error("Could not connect: " . @mysql_error());
show_errors();
}
if(!@mysql_select_db('database_name', $conn)) {
set_error("Could not select database.");
show_errors();
}
2018-09-13 15:56:12 +00:00
return $conn;
}
}
2019-02-26 05:40:03 +00:00
if(!check_function_exists("exec_db_mysql_old_query")) {
2018-09-13 15:56:12 +00:00
function exec_db_mysql_old_query($sql, $bind) {
$result = false;
$dbc = get_dbc_object();
$binded_sql = get_db_binded_sql($sql, $bind);
$result = @mysql_query($dbc, $binded_sql);
return $result;
}
}
2019-02-26 05:40:03 +00:00
if(!check_function_exists("exec_db_mysql_old_fetch_all")) {
2018-09-13 15:57:03 +00:00
function exec_db_mysql_old_fetch_all($sql, $bind) {
2018-09-13 15:56:12 +00:00
$rows = array();
2018-09-13 15:57:03 +00:00
$result = exec_db_mysql_old_query($sql, $bind);
2018-09-13 15:56:12 +00:00
while($row = @mysql_fetch_array($result)) {
$rows[] = $row;
}
return $rows;
}
}
2018-09-13 16:04:53 +00:00
2019-02-26 05:40:03 +00:00
if(!check_function_exists("close_db_mysql_old_connect")) {
2018-09-13 16:04:53 +00:00
function close_db_mysql_old_connect() {
$dbc = get_scope("dbc");
2018-09-13 16:05:26 +00:00
return mysql_close($dbc);
2018-09-13 16:04:53 +00:00
}
}