PDOException: SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near 'RLIKE'.: SELECT node.[nid] AS [entity_id], node.[vid] AS [revision_id], node.[type] AS [bundle], cross_entity_type.cross_sqlsrv AS entity_type FROM node node CROSS APPLY (SELECT :entity_type cross_sqlsrv) cross_entity_type WHERE ( ([node].[title] RLIKE :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] => privacy|privacy +policy|cookie +policy|terms +of +use|terms +of +service|terms +and +conditions [:entity_type] => node ) in _eu_cookie_compliance_find_privacy_policy() (line 597 of \sites\all\modules\eu_cookie_compliance\eu_cookie_compliance.module).

Via Drush:
PDOException: SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near 'RLIKE'. in \includes\database\sqlsrv\database.inc:952
Stack trace:
#0 \includes\database\sqlsrv\database.inc(952): PDOStatement->execute(Array)
#1 \includes\database\sqlsrv\database.inc(466): DatabaseStatement_sqlsrv->execute(Array, Array)
#2 \includes\database\select.inc(1280): DatabaseConnection_sqlsrv->query('SELECT node.[ni...', Array, Array)
#3 \includes\entity.inc(1392): SelectQuery->execute()
#4 \includes\entity.inc(1343): EntityFieldQuery->finishQuery(Object(SelectQuery_sqlsrv))
#5 \includes\entity.inc(1216): EntityFieldQuery->propertyQuery(Object(EntityFieldQuery))
#6 \sites\all\modules\eu_cookie_compliance\eu_cookie_compliance.module(597): EntityFieldQuery->execute()
#7 \sites\all\modules\eu_cookie_compliance\eu_cookie_compliance.install(79): _eu_cookie_compliance_find_privacy_policy()
#8 \includes\module.inc(926): eu_cookie_compliance_install()
#9 \includes\module.inc(494): module_invoke('eu_cookie_compl...', 'install')
#10 \Drush\commands\core\drupal\environment_7.inc(143): module_enable(Array)
#11 \Drush\commands\pm\pm.drush.inc(1122): drush_module_enable(Array)
#12 \Drush\includes\command.inc(361): drush_pm_enable('eu_cookie_compl...')
#13 \Drush\includes\command.inc(212): _drush_invoke_hooks(Array, Array)
#14 \Drush\includes\command.inc(180): drush_command('eu_cookie_compl...')
#15 \Drush\lib\Drush\Boot\BaseBoot.php(64): drush_dispatch(Array)
#16 \Drush\drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#17 \Drush\drush.php(11): drush_main()
#18 {main}

Comments:
I tested this query manually in SSMS, and it indeed fails with the same error of Incorrect syntax near 'RLIKE'.

I noticed that the switch() on eu_cookie_compliance.module:572 doesn't have a case for 'sqlsrv', and may need one.

I had to hack eu_cookie_compliance.module and add "return false;" to the beginning of the _eu_cookie_compliance_find_privacy_policy() function to by pass this issue and install the module successfully.

Comments

ryanbriscall created an issue. See original summary.

ryanbriscall’s picture

Issue summary: View changes
svenryen’s picture

Thanks. Do you know if there's a free version of ODBC Driver 13 for SQL Server I can use to test and fix the problem? Or would you be able to test a build once I get around to looking at this issue?

ryanbriscall’s picture

I'm using Microsoft SQL Server Express Edition, which is free. Yes, I can test your build.

svenryen’s picture

Thanks, I'll be in touch. It may take a few weeks though.

svenryen’s picture

Priority: Major » Normal
svenryen’s picture

Hi @ryanbriscall, do you recall that you reported a bug in EU Cookie Compliance. I'm finally getting around to looking at it. Do you still use Microsoft SQL Server Express Edition for your sites? What version would you recommend to install under Windows 7, and how do you manage the databases? Do I need an additional software or is there a command line?

Sixfold’s picture

Repost from duplicate issue https://www.drupal.org/project/eu_cookie_compliance/issues/3064563
--------------------------------

I'm currently using SQL Server 2014 Express, which can be downloaded here:
https://www.microsoft.com/en-US/download/details.aspx?id=42299

This version requires Windows 7 SP1 (see https://docs.microsoft.com/en-au/sql/sql-server/install/hardware-and-sof...)

Please be aware that you download the correct language version (according to your Windows 7 OS display language) as the installation of another language version will fail. Also I recommend downloading the setup with tools ("SQLEXPRWT_x64_ENU.exe") because that version comes bundled with SQL Server Management Studio, a great GUI tool capable of managing the databases on the server. Install SQL Server and Management Studio on your Windows 7 VM and you're all set :)

svenryen’s picture

Thanks, Sixfold. I missed the part about tools being included in SQLEXPRWT_x64_ENU (The people that come up with these windows package names seem to live in the DOS era :) ) and somehow managed to install SQL Server 2008 which didn't work at all.

I'll make another attempt today.

svenryen’s picture

Issue summary: View changes
StatusFileSize
new42.97 KB

I've tried getting MS SQL running and I've made some progress. I'm on Windows 7 SP 1.

I've installed SQL Server Express 2014, and configured it to accept connections over TCP/IP in Configuration Manager, created a new database, login and user.

I'm able to log in and administer the new database with the new user in Server Management Studio which implies that the authentication is working correctly.

I've allowed absolutely all connections in the Windows firewall.

And I've set Server Authentication to all both SQL Server and Windows Authentication.

What I can't get working is the connection in Drupal. I'm on version 1 of the sqlsrv module, and I've copied the driver to my webroot.

Also, when I try to run 'telnet [SERVER-IP] 1433' the terminal is blank. I've tried sqlcmd -U sven -P ryen -H 127.0.0.1 which gives nothing - just an empty command prompt that I have to escape out of, whereas sqlcmd -S IEWIN7\SQLEXPRESS works. (I can type GO and QUIT).

I've tried running the Drupal installation inside Windows using WAMP and the latest thread safe drivers from Github. I also tried building the .so with pecl on my Mac, attempting a remote DB installation. For both win and mac Drupals I get this error (which is empty).

I've verified using phpinfo() that the driver is indeed loaded on both envs.

I've run out of ideas, any guesses as to why I can't connect to the server?

It's going to be hard to look into this bug without access to a database server.

svenryen’s picture

I've also tried to install SQL Server via Docker (https://database.guide/how-to-install-sql-server-on-a-mac/) and I'm successful at connecting to the database from npm (mssql command to run "select @@version") and the Azure Data Studio app (where I created the database).

Drupal (and I guess also PHP), however, sadly won't see the server, no matter how hard I try.

svenryen’s picture

It really seems that I'm stuck with no SQL Server.

I followed this tutorial: https://www.microsoft.com/en-us/sql-server/developer-get-started/php/mac...
and at step 2.3 php throws an exception when I try to execute sqlsrv_connect

PHP Fatal error: sqlsrv_connect: Unknown exception caught. in /test.php on line 9

Seems like I'm out of luck. I'll try to manually run some sql queries in Azure Data Studio, but then ultimately I'll have to rely on you guys to help review the patch. Hope you can help.

Sixfold’s picture

Did take a while because I had to figure it out myself first.

By default, SQL Server Express uses dynamic TCP Ports (picking a free port upon service start). There's another service called SQL Server Browser which listens on port 1434 UDP and acts as a translation service to lookup the current TCP port of the SQL Server instance.

Therefore you have two options:
1. Enable SQL Server Browser (the service is disabled by default), make sure UDP port 1434 is accessible and configure Drupal without a port number (the SQL Server Driver should query the port from SQL Server Browser automatically)
2. Set a fixed port for SQL Server (using "SQL Server Configuration Manager" > SQL Server Network Configuration > Protocols > TCP: In the dialog, scroll all the way down until you reach the section "IPAll" and set TCP port = 1433. After a service restart, you should be good to go)

You can verify the ports currently in use with Sysinternals' tool TCPView: https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview

Hope this helps ;)

svenryen’s picture

Thanks, that helped a lot.

I had indeed found the TCP/IP settings in "SQL Server Configuration Manager", but I missed that the port had to be configured for IpAll. I had in fact set it for the ip that I would be using to connect (192.168.56.101), as well as 127.0.0.1 but seems that wasn't enough.

I got a little bit stuck, needing wincache.dll, and had to toss out the WAMPServer that I was using, and resort to installing IIS 7.5 Express, then figuring out the best way to get PHP running as fastCGI.

And everything worked. Drupal is installing with a mssql server database on windows 7 as we speak.

I might put this issue aside for a while, at least I got past the first hurdle.

svenryen’s picture

I managed to get this fixed tonight.

I'll post the patch tomorrow, I need to port it to D7 first (wrote it for D8).

svenryen’s picture

Here are the patches.
It's nice to have this resolved, so the module doesn't crash on install for those who are on SQL Server.

  • svenryen authored 363a04e on 7.x-1.x
    Issue #2991213 by svenryen, ryanbriscall, Sixfold: PDOException:...

  • svenryen authored 639a745 on 8.x-1.x
    Issue #2991213 by svenryen, ryanbriscall, Sixfold: PDOException:...
svenryen’s picture

Status: Active » Fixed
Sixfold’s picture

I installed the new release and it worked like a charm.
Big thanks @svenryen for your support and the effort you put into maintaining this really important drupal module!

Regards,
Fabian

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.