Skip to content

Commit c8a5c7c

Browse files
committed
Update to use also mysqlnd using Wordpress base class with some small
modifications
1 parent b3b6aff commit c8a5c7c

4 files changed

Lines changed: 3644 additions & 38 deletions

File tree

config.inc.php.example

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ $_config['database_db'] = "divelog";
1616
$_config['database_username'] = "divelog";
1717
$_config['database_password'] = "password";
1818

19-
/**
20-
* Define the connection type use mysqli for php5 (check if mysqli is installed), otherwise enter mysql
21-
* The driver mysqli is not used everywhere (planned)
22-
*/
23-
$_config['database_type'] = "mysqli";
24-
2519
/**
2620
* Enter prefix for single user mode (for multi user see below)
2721
*/

includes/misc.inc.php

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,7 @@ function sql_file($filename)
169169
*/
170170
function parse_mysql_query($filename, $sql_query = 0, $debug = false)
171171
{
172-
global $_config, $globals;
173-
$username = $_config['database_username'];
174-
$password = $_config['database_password'];
175-
$server = $_config['database_server'];
176-
$db = $_config['database_db'];
177-
172+
global $_config, $globals, $wpdb;
178173
$globals['sql_num_rows'] = 0;
179174
$result = array();
180175
if (($sql_query)) {
@@ -186,34 +181,14 @@ function parse_mysql_query($filename, $sql_query = 0, $debug = false)
186181
if ($debug == true) {
187182
// echo "query is: $query <br>";
188183
}
189-
$connection = mysqli_connect($server, $username, $password, $db);
190184
/* change character set to utf8 */
191-
if (!mysqli_set_charset($connection, "utf8")) {
192-
printf("Error loading character set utf8: %s\n", mysqli_error($connection));
193-
exit();
194-
}
195-
if (mysqli_connect_errno()) {
196-
printf("Connect failed: %s\n", mysqli_connect_error());
197-
exit();
198-
}
199-
$server_query = mysqli_query($connection, $query);
200-
if (mysqli_errno($connection)) {
201-
echo "<hr>\n<b>MySQL error " . mysqli_errno($connection) . ": " . mysqli_error($connection) . "\n:</b><br>\n";
202-
echo "Query: $query <br><hr>";
203-
exit;
204-
}
205-
$globals['sql_num_rows'] = mysqli_affected_rows($connection);
185+
$wpdb->set_charset($wpdb->dbh, "utf8");
186+
$res = $wpdb->get_results($query,ARRAY_A );
187+
$globals['sql_num_rows'] = $wpdb->num_rows; //mysqli_affected_rows($connection);
206188
if ($globals['sql_num_rows'] == 1) {
207-
$result = mysqli_fetch_assoc($server_query);
189+
$result = $res[0];
208190
} else {
209-
for ($i = 0; $query_output = mysqli_fetch_assoc($server_query); $i++) {
210-
foreach ($query_output as $key => $val) {
211-
if (is_string($val)) {
212-
$query_output[$key] = $val;
213-
}
214-
}
215-
$result[$i] = $query_output;
216-
}
191+
$result = $res;
217192
}
218193
}
219194
return $result;
@@ -890,7 +865,7 @@ function distInvVincenty($lat1, $lon1, $lat2, $lon2)
890865

891866

892867

893-
function ($atRoot = FALSE, $atCore = FALSE, $parse = FALSE)
868+
function base_url($atRoot = FALSE, $atCore = FALSE, $parse = FALSE)
894869
{
895870
if (isset($_SERVER['HTTP_HOST'])) {
896871
$http = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';

0 commit comments

Comments
 (0)