Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=3469)
This modification will add MySQLi support to SMF.
It is a simple install the package and change your settings
From
$db_type = mysql';
To:
$db_type = mysqli';
Please ensure that you have mysqli installed before using this modification. If it doesn't work then just revert your db_type to mysql.
IMPORTANT: As of SMF 2.0.14 this Mod is no longer required.
Revision History :
1.0.0 - Initial Release
1.0.1 - Bug fix to full text search API functionality.
1.0.2 - Added Fixes from later versions of SMF
Quote
Copyright © 2012 tinoest. All rights reserved.
Developed by: tinoest
http://www.tinoest.no-ip.org
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
3. Neither the names of tinoest, nor the names of its contributors may be
used to endorse or promote products derived from this Software without
specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
WITH THE SOFTWARE.
This license may be viewed online at http://opensource.org/licenses/BSD-3-Clause
any problem with those control?
if ($db_type == 'mysql')
line 363 in ManageSearch.php
if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
line 468 in ScheduledTasks.php
$context['convert_utf8'] = $db_type == 'mysql' && (!isset($db_character_set) || $db_character_set !== 'utf8' || empty($modSettings['global_character_set']) || $modSettings['global_character_set'] !== 'UTF-8') && version_compare('4.1.2', preg_replace('~\-.+?$~', '', $smcFunc['db_server_info']())) <= 0;
$context['convert_entities'] = $db_type == 'mysql' && isset($db_character_set, $modSettings['global_character_set']) && $db_character_set === 'utf8' && $modSettings['global_character_set'] === 'UTF-8';
line 212 and 213 in ManageMaintenance.php
ManageMaintenance.php
thank u
Quote from: hhy89 on September 30, 2012, 06:15:05 AM
any problem with those control?
if ($db_type == 'mysql')
line 363 in ManageSearch.php
if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
line 468 in ScheduledTasks.php
$context['convert_utf8'] = $db_type == 'mysql' && (!isset($db_character_set) || $db_character_set !== 'utf8' || empty($modSettings['global_character_set']) || $modSettings['global_character_set'] !== 'UTF-8') && version_compare('4.1.2', preg_replace('~\-.+?$~', '', $smcFunc['db_server_info']())) <= 0;
$context['convert_entities'] = $db_type == 'mysql' && isset($db_character_set, $modSettings['global_character_set']) && $db_character_set === 'utf8' && $modSettings['global_character_set'] === 'UTF-8';
line 212 and 213 in ManageMaintenance.php
ManageMaintenance.php
thank u
I can't see any reason there would be. Are you having any issues?
i dont use it now but ill use later. and if i get any error, i will say.
thanks for this good work
what would be the benefits of using this MOD? thanks for making it.
Quote from: humbleworld on November 22, 2012, 04:48:19 PM
what would be the benefits of using this MOD? thanks for making it.
You have to judge in the benefits listed here are sufficient to change. Some hosts also don't provide MySQL now as its been depreciated in PHP 5.4
http://www.php.net/manual/en/mysqli.overview.php
An object-oriented interface
Support for prepared statements
Support for multiple statements
Support for transactions
Enhanced debugging support
Embedded server support
Does this mod also work on SMF 1.1.X when manually installed?
No. SMF 1.1.x does not have a database abstraction layer. It uses the raw mysql_* functions in every file. So, as you may imagine, this mod will be a total nightmare to backport.
I must be really blind I can not find where I switch that setting
Switch what setting? Would you mind elaborating.
Quote from: tinoest on September 21, 2012, 05:28:40 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3469)
This modification will add MySQLi support to SMF.
It is a simple install the package and change your settings
From
$db_type = mysql';
To:
$db_type = mysqli';
this setting. I can't find it.
Edit your Settings.php. ;)
Ok well in that case I have a larger problem cause I do not have that line in my settings file
What version of SMF?
2.0.5
Then there is absolutely no reason for you not to have a line that starts $db_type in your Settings.php file. In fact it shouldn't work properly without it.
<?php
/**********************************************************************************
* Settings.php *
***********************************************************************************
* SMF: Simple Machines Forum *
* Open-Source Project Inspired by Zef Hemel ([email protected]) *
* =============================================================================== *
* Software Version: SMF 1.1 *
* Software by: Simple Machines (http://www.simplemachines.org) *
* Copyright 2006 by: Simple Machines LLC (http://www.simplemachines.org) *
* 2001-2006 by: Lewis Media (http://www.lewismedia.com) *
* Support, News, Updates at: http://www.simplemachines.org *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under *
* the terms of the provided license as published by Simple Machines LLC. *
* *
* This program is distributed in the hope that it is and will be useful, but *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* See the "license.txt" file for details of the Simple Machines license. *
* The latest version can always be found at http://www.simplemachines.org. *
**********************************************************************************/
########## Maintenance ##########
# Note: If $maintenance is set to 2, the forum will be unusable! Change it to 0 to fix it.
$maintenance = 0; # Set to 1 to enable Maintenance Mode, 2 to make the forum untouchable. (you'll have to make it 0 again manually!)
$mtitle = 'Updating'; # Title for the Maintenance Mode message.
$mmessage = 'To improve the safety on the forum we are doing a small security update'; # Description of why the forum is in maintenance mode.
########## Forum Info ##########
$mbname = 'Dubberz Forums'; # The name of your forum.
$language = 'english'; # The default language file set for the forum.
$boardurl = 'http://dubberz.com/forum'; # URL to your forum's folder. (without the trailing /!)
$webmaster_email = '[email protected]'; # Email address to send emails from. (like [email protected].)
$cookiename = '************'; # Name of the cookie to set for authentication.
########## Database Info ##########
$db_server = '127.0.0.1';
$db_name = '************';
$db_user = '************';
$db_passwd = '************';
$db_prefix = 'smf_';
$db_persist = 0;
$db_error_send = 0;
########## Directories/Files ##########
# Note: These directories do not have to be changed unless you move things.
$boarddir = '************'; # The absolute path to the forum's folder. (not just '.'!)
$sourcedir = '************'; # Path to the Sources directory.
########## Error-Catching ##########
# Note: You shouldn't touch these settings.
$db_last_error = 1282157429;
# Make sure the paths are correct... at least try to fix them.
if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
$boarddir = dirname(__FILE__);
if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources'))
$sourcedir = $boarddir . '/Sources';
$cachedir = '*****';
$ssi_db_user = '';
?>
I direct your attention to:
Quote* Software Version: SMF 1.1 *
However if you really are using 2.0 (since the upgrader should replace that part of the settings file), you can just add:
$db_type = 'mysqli';
under where all the other $db settings are.
Quote from: Arantor on October 22, 2013, 10:50:04 AM
I direct your attention to:
Quote* Software Version: SMF 1.1 *
um so how does that work.......
(http://www.dubberz.com/uploads/version.jpg)
I don't know, but you can still change it as directed above.
Weird I tried that last night and it didn't work....This morning it was fine.
When db_type is set to mysqli, and something is searched in the advanced search, it gives a blank page and the following error in the error log:
index.php?action=search2
8: Undefined variable: smcFunc
File: Sources/SearchAPI-Fulltext.php
Line: 138
In the quick search box (in the top right) this error doesn't pop though, only when using advanced search.
When the db_type is swapped back to mysql the error goes away and advanced search is useable like expected.
SearchAPI-Fulltext.php is character for character the same thing as the base SMF install (no mod's or anything have changed it or added custom code).
If the function prepareIndexes is changed (basically adding global smcFunc) in that file to:
public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded)
{
global $modSettings, $smcFunc;
It works the same as the mysql way works, but is this the 'wrong' way to fix it? Since the mysqli db_type seems to have this problem and not the old mysql way.
I had the same issue. I just replaced with google instead.
Quote from: riou on October 28, 2013, 11:08:30 PM
When db_type is set to mysqli, and something is searched in the advanced search, it gives a blank page and the following error in the error log:
index.php?action=search2
8: Undefined variable: smcFunc
File: Sources/SearchAPI-Fulltext.php
Line: 138
In the quick search box (in the top right) this error doesn't pop though, only when using advanced search.
When the db_type is swapped back to mysql the error goes away and advanced search is useable like expected.
SearchAPI-Fulltext.php is character for character the same thing as the base SMF install (no mod's or anything have changed it or added custom code).
If the function prepareIndexes is changed (basically adding global smcFunc) in that file to:
public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded)
{
global $modSettings, $smcFunc;
It works the same as the mysql way works, but is this the 'wrong' way to fix it? Since the mysqli db_type seems to have this problem and not the old mysql way.
Can you confirm if changing this in that file solves the issue.
From this :
protected $supported_databases = array('mysql');
To this :
protected $supported_databases = array('mysql' , 'mysqli');
Quote from: tinoest on December 18, 2013, 06:41:40 PM
Quote from: riou on October 28, 2013, 11:08:30 PM
When db_type is set to mysqli, and something is searched in the advanced search, it gives a blank page and the following error in the error log:
index.php?action=search2
8: Undefined variable: smcFunc
File: Sources/SearchAPI-Fulltext.php
Line: 138
In the quick search box (in the top right) this error doesn't pop though, only when using advanced search.
When the db_type is swapped back to mysql the error goes away and advanced search is useable like expected.
SearchAPI-Fulltext.php is character for character the same thing as the base SMF install (no mod's or anything have changed it or added custom code).
If the function prepareIndexes is changed (basically adding global smcFunc) in that file to:
public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded)
{
global $modSettings, $smcFunc;
It works the same as the mysql way works, but is this the 'wrong' way to fix it? Since the mysqli db_type seems to have this problem and not the old mysql way.
Can you confirm if changing this in that file solves the issue.
From this :
protected $supported_databases = array('mysql');
To this :
protected $supported_databases = array('mysql' , 'mysqli');
That does fix it, yes :)
Hi,
I've updated the package based upon the above bug report. It should work OK now.
Thanks for the feedback.
With mysql 5.6 this version needs the same fix the base smf got in version 2.0.8 in its Subs-Db-mysql file (same as Arantor's mod did: http://custom.simplemachines.org/mods/index.php?mod=3865 ) to allow it to properly sort the boards
There was also an edit in 2.0.9 (to the base mysql version)
find:
if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && strpos($db_string, 'INSERT INTO') === false)
replace that with:
if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
Assume this would also need changed for the mysqli version?
Hi,
The 1.0.1 package is being recognised correctly but 1.0.2 is not. The error when uploading it is:
QuoteAn Error Has Occurred!
Package upload failed due to the following error:
"Although the package was downloaded to the server it appears to be empty. Please check the Packages directory, and the "temp" sub-directory are both writable. If you continue to experience this problem you should try extracting the package on your PC and uploading the extracted files into a subdirectory in your Packages directory and try again. For example, if the package was called shout.tar.gz you should:
1) Download the package to your local PC and extract it into files.
2) Using an FTP client create a new directory in your "Packages" folder, in this example you may call it "shout".
3) Upload all the files from the extracted package to this directory.
4) Go back to the package manager browse page and the package will be automatically found by SMF."
I've checked and the ZIP file extracts fine.
Edit: I noticed that the only file change that had been made was with "Subs-Db-mysqli.php" so I basically overwrote it. It's apparently working with PHP 7.1 on my setup.
Cheers
Following up on my last comment, I had to disable Database driven sessions, the board wouldn't run properly otherwise. I couldn't even log in the admin backend, so I had to manually change the value in the database "_settings" > "databaseSession_enable"
The related errors in the database were:
"2: session_start(): Failed to read session data: user (path: /tmp)" - I changed it to another folder and it still wouldn't make a difference.
"2: Parameter 1 to optimus_buffer() expected to be a reference, value given" - regarding PHPSESSION
(I'm still getting the second error though - a lot)
Anyone guide me how to install this manually?
i'm trying to get 2.0x to work on php 7 but i seem to get this error on installation page.
Critical Error!
The installer was unable to detect any database support in PHP. Please ask your host to ensure that PHP was compiled with the desired database, or that the proper extension is being loaded
Maybe this can help you; Manual Installation of Mods (http://wiki.simplemachines.org/smf/Manual_installation_of_mods)
This mod brakes the admin panel with 2.0.15 because it does not provide che $smcFunc['db_get_engine'] method.
The fix is simple. Just open DBExtra-mysqli.php, in db_extra_init() add this to the array:
'db_get_engine' => 'smf_db_get_engine'
And then copy the smf_db_get_engine() function from DBExtra-mysql.php and paste it on the bottom.
Quote from: caribe1999 on November 25, 2017, 02:15:16 AM
This mod brakes the admin panel with 2.0.15 because it does not provide che $smcFunc['db_get_engine'] method.
The fix is simple. Just open DBExtra-mysqli.php, in db_extra_init() add this to the array:
'db_get_engine' => 'smf_db_get_engine'
And then copy the smf_db_get_engine() function from DBExtra-mysql.php and paste it on the bottom.
This mod is no longer required since 2.0.14 and I'd recommend removing it.
Ah... ok.
To elaborate: SMF 2.0.14 includes this driver.