mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Added option charset to db_connect
Removed unused function db_get_table_count
This commit is contained in:
parent
21c9a7ee4a
commit
7766881da6
@ -14,7 +14,7 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
function mysql_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null) {
|
function mysql_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null, $charset = "utf8") {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($host === null)
|
if ($host === null)
|
||||||
@ -42,6 +42,8 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null,
|
|||||||
}
|
}
|
||||||
db_change_cache_id ($db, $host);
|
db_change_cache_id ($db, $host);
|
||||||
|
|
||||||
|
mysqli_set_charset($connect_id, $charset);
|
||||||
|
|
||||||
mysqli_select_db($connect_id, $db);
|
mysqli_select_db($connect_id, $db);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -52,6 +54,8 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null,
|
|||||||
|
|
||||||
db_change_cache_id ($db, $host);
|
db_change_cache_id ($db, $host);
|
||||||
|
|
||||||
|
@mysql_set_charset($connect_id, $charset);
|
||||||
|
|
||||||
mysql_select_db($db, $connect_id);
|
mysql_select_db($db, $connect_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1198,47 +1202,6 @@ function mysql_db_get_type_field_table($table, $field) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the element count of a table.
|
|
||||||
*
|
|
||||||
* @param string $sql SQL query to get the element count.
|
|
||||||
*
|
|
||||||
* @return int Return the number of elements in the table.
|
|
||||||
*/
|
|
||||||
function mysql_db_get_table_count($sql, $search_history_db = false) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$history_count = 0;
|
|
||||||
$count = mysql_db_get_value_sql ($sql);
|
|
||||||
if ($count === false) {
|
|
||||||
$count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search the history DB for matches
|
|
||||||
if ($search_history_db && $config['history_db_enabled'] == 1) {
|
|
||||||
|
|
||||||
// Connect to the history DB
|
|
||||||
if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) {
|
|
||||||
if ($config["mysqli"]) {
|
|
||||||
$config['history_db_connection'] = mysqli_connect_db ($config['history_db_host'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_name'], $config['history_db_port'], false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$config['history_db_connection'] = mysql_connect_db ($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($config['history_db_connection'] !== false) {
|
|
||||||
$history_count = mysql_db_get_value_sql ($sql, $config['history_db_connection']);
|
|
||||||
if ($history_count === false) {
|
|
||||||
$history_count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$count += $history_count;
|
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mysql_get_fields($table) {
|
function mysql_get_fields($table) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -1476,42 +1476,6 @@ function oracle_list_all_field_table($table_name, $return_mode = 'array') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the element count of a table.
|
|
||||||
*
|
|
||||||
* @param string $sql SQL query to get the element count.
|
|
||||||
*
|
|
||||||
* @return int Return the number of elements in the table.
|
|
||||||
*/
|
|
||||||
function oracle_db_get_table_count($sql, $search_history_db = false) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$history_count = 0;
|
|
||||||
$count = oracle_db_get_value_sql ($sql);
|
|
||||||
if ($count === false) {
|
|
||||||
$count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search the history DB for matches
|
|
||||||
if ($search_history_db && $config['history_db_enabled'] == 1) {
|
|
||||||
|
|
||||||
// Connect to the history DB
|
|
||||||
if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) {
|
|
||||||
$config['history_db_connection'] = oracle_connect_db ($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false);
|
|
||||||
}
|
|
||||||
if ($config['history_db_connection'] !== false) {
|
|
||||||
$history_count = oracle_db_get_value_sql ($sql, $config['history_db_connection']);
|
|
||||||
if ($history_count === false) {
|
|
||||||
$history_count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$count += $history_count;
|
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a file with an oracle schema sentences.
|
* Process a file with an oracle schema sentences.
|
||||||
* Based on the function which installs the pandoradb.sql schema.
|
* Based on the function which installs the pandoradb.sql schema.
|
||||||
|
@ -1055,40 +1055,5 @@ function postgresql_db_get_type_field_table($table, $field) {
|
|||||||
return pg_field_type($result, $field);
|
return pg_field_type($result, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the element count of a table.
|
|
||||||
*
|
|
||||||
* @param string $sql SQL query to get the element count.
|
|
||||||
*
|
|
||||||
* @return int Return the number of elements in the table.
|
|
||||||
*/
|
|
||||||
function postgresql_db_get_table_count($sql, $search_history_db = false) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$history_count = 0;
|
|
||||||
$count = postgresql_db_get_value_sql ($sql);
|
|
||||||
if ($count === false) {
|
|
||||||
$count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search the history DB for matches
|
|
||||||
if ($search_history_db && $config['history_db_enabled'] == 1) {
|
|
||||||
|
|
||||||
// Connect to the history DB
|
|
||||||
if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) {
|
|
||||||
$config['history_db_connection'] = postgresql_connect_db ($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false);
|
|
||||||
}
|
|
||||||
if ($config['history_db_connection'] !== false) {
|
|
||||||
$history_count = postgresql_db_get_value_sql ($sql, $config['history_db_connection']);
|
|
||||||
if ($history_count === false) {
|
|
||||||
$history_count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$count += $history_count;
|
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -43,13 +43,13 @@ function db_select_engine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_connect($host = null, $db = null, $user = null, $pass = null, $port = null, $critical = true) {
|
function db_connect($host = null, $db = null, $user = null, $pass = null, $port = null, $critical = true, $charset = "utf8") {
|
||||||
global $config;
|
global $config;
|
||||||
static $error = 0;
|
static $error = 0;
|
||||||
|
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
$return = mysql_connect_db($host, $db, $user, $pass, $port);
|
$return = mysql_connect_db($host, $db, $user, $pass, $port, $charset);
|
||||||
break;
|
break;
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
$return = postgresql_connect_db($host, $db, $user, $pass, $port);
|
$return = postgresql_connect_db($host, $db, $user, $pass, $port);
|
||||||
@ -1654,28 +1654,12 @@ function db_get_type_field_table($table, $field) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the element count of a table.
|
* Get the columns of a table.
|
||||||
*
|
*
|
||||||
* @param string $sql SQL query to get the element count.
|
* @param string $table table to retrieve columns.
|
||||||
*
|
*
|
||||||
* @return int Return the number of elements in the table.
|
* @return array with column names.
|
||||||
*/
|
*/
|
||||||
function db_get_table_count($table, $search_history_db = false) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
switch ($config["dbtype"]) {
|
|
||||||
case "mysql":
|
|
||||||
return mysql_db_get_table_count($table, $search_history_db);
|
|
||||||
break;
|
|
||||||
case "postgresql":
|
|
||||||
return postgresql_db_get_table_count($table, $search_history_db);
|
|
||||||
break;
|
|
||||||
case "oracle":
|
|
||||||
return oracle_db_get_table_count($table, $search_history_db);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function db_get_fields($table) {
|
function db_get_fields($table) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user