thorsten / phpMyFAQ

phpMyFAQ - Open Source FAQ web application for PHP 8.1+ and MySQL, PostgreSQL and other databases
https://www.phpmyfaq.de
Mozilla Public License 2.0
582 stars 253 forks source link

DB Tables not created at installation on SQL Server #3037

Closed AEhlers27 closed 1 day ago

AEhlers27 commented 4 days ago

The cration of data tables at installtion does not work on MS SQL Server. The database ist empty. When i try older version of phpMyFAQ (3.1.18) the tables are created.

The script shows error:

Installation INSERT INTO IT_faqstopwords (id, lang, stopword) VALUES (0, 'cs', 'dnes')42S02: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Ungültiger Objektname "IT_faqstopwords". Fatal error: Uncaught Exception: Error while fetching result: 42S02: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Ungültiger Objektname "IT_faqconfig". in C:...\src\phpMyFAQ\Database\Sqlsrv.php:116 Stack trace:

0 C:...\src\phpMyFAQ\Configuration.php(220): phpMyFAQ\Database\Sqlsrv->fetchAll(false)

1 C:...\src\phpMyFAQ\Configuration.php(194): phpMyFAQ\Configuration->getAll()

2 C:...\src\phpMyFAQ\Link.php(203): phpMyFAQ\Configuration->get('security.useSsl...')

3 C:...\src\phpMyFAQ\Link.php(193): phpMyFAQ\Link->getSystemScheme()

4 C:...\src\phpMyFAQ\Setup\Installer.php(1011): phpMyFAQ\Link->getSystemUri('/setup/index.ph...')

5 C:...\setup\index.php(437): phpMyFAQ\Setup\Installer->startInstall()

6 {main} thrown in C:...\src\phpMyFAQ\Database\Sqlsrv.php on line 116

phpMyFAQ version : 3.2.7 PHP version: 8.2.5 Database: SQL Server 2022 Elasticsearch yes/no: no

thorsten commented 4 days ago

That's strange, because there's no difference between 3.1 and 3.2 for the stopwords table.

AEhlers27 commented 4 days ago

I found two things in the table creation (\src\phpMyFAQ\Instance\Database\Sqlsrv.php): Table faqadminlog: replace text NVARCHAR(8000) NOT NULL, witch text NVARCHAR(4000) NOT NULL,

nvarchar[(n)] : n has to be between 1 and 4000

Table faqbackup: replace id INT(11) NOT NULL, with id INT NOT NULL,

Now the tables are created, but i run into next error:

Fatal error: Uncaught TypeError: phpMyFAQ\Configuration::add(): Return value must be of type object|bool, resource returned in C:...\src\phpMyFAQ\Configuration.php:370 Stack trace:

0 C:...\src\phpMyFAQ\Setup\Installer.php(1008): phpMyFAQ\Configuration->add('main.currentVer...', '3.2.7')

1 C:...\setup\index.php(437): phpMyFAQ\Setup\Installer->startInstall()

2 {main} thrown in C:...\src\phpMyFAQ\Configuration.php on line 370