X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb%2Fconnect_db.inc;h=81bad397bc8641292efadea7fb1235ca230bbc8e;hb=c34e563fae8003a637a485b4eaf634678b90c60f;hp=e899eac786553a8d1abcb7036c3809d246111855;hpb=0b63d898491b6577a5a5bf90e771dca0dcbbcf1f;p=fa-stable.git diff --git a/includes/db/connect_db.inc b/includes/db/connect_db.inc index e899eac7..81bad397 100644 --- a/includes/db/connect_db.inc +++ b/includes/db/connect_db.inc @@ -10,12 +10,12 @@ See the License here . ***********************************************************************/ //$path_to_root=".."; +define('MAX_DEADLOCK_RETRY', 3); - -if (strncmp(phpversion(), "5.4", 3) >= 0) // mysql_... functions deprecated from php 5.5 +if (function_exists('mysqli_connect')) include_once("connect_db_mysqli.inc"); -else - include_once("connect_db_mysql.inc"); +else + include_once("connect_db_mysql.inc"); // use deprecated mysql_* API as fallback on old servers function db_get_version() { @@ -62,35 +62,35 @@ function get_mysql_encoding_name($encoding) } /* - Returns 'best' collation for various locale language codes + Returns 'best' mysql collation for various FA backend language codes. */ function get_mysql_collation($lang=null) { if (!$lang) - $lang = substr($_SESSION['language']->code, 0, 2); + $lang = 'utf8_'.substr($_SESSION['language']->code, 0, 2); $db_collation = array( - 'is' => 'icelandic', - 'lv' => 'latvian', - 'ro' => 'romanian', - 'sl' => 'slovenian', - 'pl' => 'polish', - 'et' => 'estonian', - 'es' => 'spanish', // or 'spanish2', - 'sw' => 'swedish', - 'tr' => 'turkish', - 'cs' => 'czech', - 'da' => 'danish', - 'lt' => 'lithuanian', - 'sk' => 'slovak', - 'sp' => 'spanish2', - 'fa' => 'persian', - 'hu' => 'hungarian', - 'fr' => 'roman', - 'it' => 'roman', + 'utf8_is' => 'utf8_icelandic_ci', + 'utf8_lv' => 'utf8_latvian_ci', + 'utf8_ro' => 'utf8_romanian_ci', + 'utf8_sl' => 'utf8_slovenian_ci', + 'utf8_pl' => 'utf8_polish_ci', + 'utf8_et' => 'utf8_estonian_ci', + 'utf8_es' => 'utf8_spanish_ci', // or 'spanish2', + 'utf8_sw' => 'utf8_swedish_ci', + 'utf8_tr' => 'utf8_turkish_ci', + 'utf8_cs' => 'utf8_czech_ci', + 'utf8_da' => 'utf8_danish_ci', + 'utf8_lt' => 'utf8_lithuanian_ci', + 'utf8_sk' => 'utf8_slovak_ci', + 'utf8_sp' => 'utf8_spanish2_ci', + 'utf8_fa' => 'utf8_persian_ci', + 'utf8_hu' => 'utf8_hungarian_ci', + 'utf8_fr' => 'utf8_roman_ci', + 'utf8_it' => 'utf8_roman_ci', ); - return 'utf8_'.(isset($db_collation[$lang]) ? $db_collation[$lang] : 'general').'_ci'; + return isset($db_collation[$lang]) ? $db_collation[$lang] : 'utf8_unicode_ci'; } /* @@ -109,12 +109,32 @@ function db_fixed() /* Check database default charset. */ -function db_get_charset() +function db_get_default_charset() { $result = db_query("SELECT @@character_set_database"); $var = db_fetch($result); return $var[0]; } - -?> \ No newline at end of file +function db_get_view_schema($view) +{ + global $db; + $schema = NULL; + $qry = "select view_definition from information_schema.views where table_schema=DATABASE() and table_name='$view'"; + $res = db_query($qry,'Failed to select view schema'); + if ($res && db_num_rows($res) == 1) { + $row = db_fetch_assoc($res); + $schema = $row['view_definition']; + } + return $schema; +} + +/* + SQL db profiling stub +*/ +if (!function_exists('db_profile')) +{ + function db_profile($sql=false) + { + } +}