return $var[0];
}
-
+/*
+ SQL db profiling stub
+*/
+if (!function_exists('db_profile'))
+{
+ function db_profile($sql=false)
+ {
+ }
+}
\ No newline at end of file
{
global $db, $show_sql, $sql_trail, $select_trail, $go_debug, $sql_queries, $Ajax,
$db_connections, $db_last_inserted_id;
-
+
// set current db prefix
$comp = isset($_SESSION["wa_current_user"]->cur_con) ? $_SESSION["wa_current_user"]->cur_con : 0;
$cur_prefix = $db_connections[$comp]['tbpref'];
$sql_queries .= "<pre>$sql</pre>\n<hr>";
}
- // mysql profiling
- global $profile_sql;
- if (@$profile_sql)
- get_usec();
+ db_profile(); // mysql profiling
+
$result = mysql_query($sql, $db);
- if (@$profile_sql)
- {
- $profile_sql= false;
- _vd($sql.'<br>:'.db_num_rows($result).'rows, '.get_usec());
- }
-
+
+ db_profile($sql);
+
if($sql_trail) {
$db_last_inserted_id = mysql_insert_id($db); // preserve in case trail insert is done
if ($select_trail || (strstr($sql, 'SELECT') === false)) {
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
+define('SQL_MODE', 'STRICT_ALL_TABLES,NO_ZERO_IN_DATE');
function set_global_connection($company=-1)
{
///// This non empty sql_mode values can interphere with FA, so all is set empty during
///// our sessions.
///// We are, however, investigating the existing code to be compatible in the future.
- if (strncmp(db_get_version(), "5.6", 3) >= 0)
- db_query("SET sql_mode = ''");
+// if (strncmp(db_get_version(), "5.6", 3) >= 0)
+ db_query("SET sql_mode = '".SQL_MODE."'");
/////
return $db;
}
$sql_queries .= "<pre>$sql</pre>\n<hr>";
}
- // mysql profiling
- global $profile_sql;
- if (@$profile_sql)
- get_usec();
+ db_profile(); // mysql profiling
+
$result = mysqli_query($db, $sql);
- if (@$profile_sql)
- {
- $profile_sql= false;
- _vd($sql.'<br>:'.db_num_rows($result).'rows, '.get_usec());
- }
-
+
+ db_profile($sql);
+
if($sql_trail) {
$db_last_inserted_id = mysqli_insert_id($db); // preserve in case trail insert is done
if ($select_trail || (strstr($sql, 'SELECT') === false)) {
// site default encoding is presumed as encoding for all databases!
$lang = array_search_value($dflt_lang, $installed_languages, 'code');
$new_encoding = get_mysql_encoding_name(strtoupper($lang['encoding']));
- // get_usec();
+
if ($test)
error_log('Switching database to utf8 encoding from '.$old_encoding);
$collation = get_mysql_collation();
$tresult = db_query($tsql, "Cannot select all tables with prefix '$pref'");
while($tbl = db_fetch($tresult)) {
$table = $tbl[0];
- // if ($table != '1_chart_master') continue; _vd($table); get_usec(); // fast debug on single table
db_query("ALTER TABLE `$table` CONVERT TO CHARACTER SET $old_encoding"); // convert encoding on utf-8 tables