Can't work with MS SQL database in Doctrine 2 - php

I am trying to connect to MS SQL database in Doctrine 2.0, but I get this error all the time: Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'.
I have already found that I need to install PDO SqlSrv extension to my local PHP (using Wamp), so I have done it (copied dlls into ext folder, edited php.ini, restarted), but the problem is still the same. I am trying to use some drivers I have downloaded, name of the file is SQLSRV20.EXE. In Doctrine config I have this as a driver: pdo_sqlsrv.
Has anybody same experience or is here just somebody who knows what have I to do to make it work?

I had a heck of a job trying to get PDO driver's working - it turned out i just needed to reboot my system.
..this shouldn't have been necessary but it did work. So if you are sure you have taken all the steps necessary to enable the drivers and it's still not working, give the reboot a shot.

Related

After snapshot boot : Informix Client -23101 / Oracle instant client -28759

Not to waste your time, I'll describe what I had && what I have now. My apps are written on php. They live on redhat6 server with nginx + apache web servers. We store data in MySQL DB, but we have lots of imports from Oracle and IBM Informix DB's, & mssql. For Oracle & Informix I have installed clients && compiled libraries pdo_oci.so & pdo_informix.so . For a few months they were working as expected.
But a week ago, admins made a snapshot of out virtual server, and reloaded it. Now only MySQL and mssql connectors work, and Oracle & IBM clients thows errors.
Oracle : -28759
Failed : SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-28759: failure to open file (/usr/local/src/php-5.3.3/ext/pdo_oci/oci_driver.c:579)/opt/project/www/test.php149
IBM Informix : -23101
Failed : SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23101./opt/project/www/test.php146
Well, as official documentations says, Informix error is connected with the lost env variables of DB_LOACALE & CLIENT_LOCALE...etc.
This is strange, because all this time I was using this string for my connections :
$dbh = new PDO ("informix:host=example.ru; database=some_db; server=db_net; CursorBehavior=0; DB_LOCALE=en_US.57372; CLIENT_LOCALE=en_US.57372;", "db_login", "pass");
I tried to set up this env variables for apache (httpd) , but this error still accures. Now I have this variables set after server reboot, but no success. May be I'am doing something wrong or at the wrong place or user name...
About Oracle , documentation says that it is connected with files loading:
And the web doc says that it is mostly ssl error and is connected with the trouble of the client, that can not find SSL Wallet files. I Have TCPS secure connection to Oracle DB with wallet, and I remember that it was a real trouble to make Instant client to look at the right place. More than that, I have client tracing enabled, but it is writing log only when I use sqlplus directly from terminal. When I run my php scripts, I got only errors and no log.
Questions:
How to enable Informix variables correctly, or how to resolve this
issue in different way.
How to enable "net tracing" for oracle, to
see what he is looking for?
How to store this variables for future
reboots/reloads/snapshots...etc. ?
People. Enable tracing of all what is possible and use "strace" command to check where programm is failing!!!
Thanks to Luís Marques! I found gls in my logs and tried to make link for it.. to real IBM/informix/gls... than another msg trouble acured.../ I made soft link from /usr/informix to my real /opt/IBM/informix and all connections successfully woke up!
Thank you man. You really helped me to finish this trouble. I post this as ansver but will accept yours as thanks to you! =)
This may be related to file / dir permissions rather than env variables.
The oracle error seems to indicated that it can no longer open/read the files it requires.
The informix -23101 error can also be caused by the driver being unable to read GLS files required for locale support.
Does the apache user have access to the Informix Client SDK directories and files?

Laravel: Connecting to sqlite database throws "PDOException: Could not find driver"

I am deploying a Laravel project to a shared hosting and added a php.ini with:
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
In phpinfo, I could also see that the sqlite extensions are loaded. Testing to connect to the database with the following code snippets also worked:
<?php
try {
$dbh = new PDO("sqlite:app/database/production.sqlite");
echo "Connected to database!";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
However, when trying to connect to the databse using Laravel, the application throws me the PDOException error.
Appreciate any help on this. Thanks in advance!
The exception you get:
PDOException: Could not find driver
is given by PHP's PDO whenever the driver to your database could not be found. PDO needs a driver to operate with different databases (e.g. Sqlite, Mysql, ...). And PDO looks for the driver based on the DSN. In your case the DSN is:
sqlite:app/database/production.sqlite
And for the driver is looked only in the part before the first colon (":"):
sqlite
The string sqlite is used to find the sqlite3 driver (see PDO_SQLITE DSN in the PHP manual).
There is only a single place in all PDO where this exception is thrown (php 5.4 lxr) and it only gets thrown in case for the text before the colon in the DSN no driver could be found. This is also what you can expect from the error message.
As you've already done the checks outlined in the best answer to "How to determine if PDO is enabled in PHP" you are already certain that the PDO sqlite extension has been loaded.
Just to make this clear: The PHP extension which contains the PDO driver for sqlite is named pdo_sqlite which you have checked to be loaded.
The only explanation I have is that you did load the extension but PHP was not able to load the driver. According to PHP sources (php 5.4 lxr) this can have exactly two reasons:
The PDO driver requires a different PDO API version
PDO must be loaded before loading any PDO drivers
(technically there is a third reason but it should be ignored: adding the driver to the hashtable of PDO drivers failed, this is pretty internal and has nothing to do specifically with PDO)
As the extension is loaded, but the driver is not found, I suspect there was a problem registering the PDO driver. You should checkout the PHP error log for startup errors. As you say you have this problem on a shared hoster you need to contact the support where you find the PHP error log. You're looking for startup errors. Sometimes these error are also shown in the error log of the webserver depending on which PHP SAPI interface is used.
Please also provide the information from phpinfo() so that additional guidance can be given. With the information you've provided you can rest assured that the sqlite driver for PDO has not been loaded. This is a configuration issue.

log4php failed connecting to mysql-cluster database in ubuntu12.04

all,
My log4php gets this error in a new server environment.
PHP Warning: log4php: [LoggerAppenderPDO:default]: Failed connecting to database. Closing appender. Error: could not find driver in ../log4php/LoggerAppender.php on line 283
I have the same settings for log4php (1. config.xml file 2.same log4php version) as my local development, which works perfectly. I tried simply log to a file in the new server, it works, which means the log4php lib has no problem. And I can even log to the database in the new server from my local script using local log4php lib, which means my server can recognize log4php logging.
I think this should related to the authentication to the database from the server itself. But have no idea what is the problem and how to solve it. Any idea?
Work around:
After some searches and tests(script using PDO not mysqli to connect to the database,reference here) , I confirm the problem is caused by lacking of pdo_mysql related driver, as akluth pointed out. I tried to re-install php5-mysql, but it failed, I tried to modify php.ini, got more errors. I think that is because the mysql-cluster settings maybe different from normal mysql. As the new server is a production server, we decide not to touch it and move the scripts to other server with normal mysql settings.

db2_connect to as400 with php and wamp server

I have been trying to connect to a ibm db2 database but it seems impposible. The as400 is in a different server than the one running php.
Everytime I do a db2_connect I get the following error:
Fatal error: Call to undefined function db2_connect()
How can I make this function work?
Tip: I've already tried with odbc and it was a lost of time, but I'm open to suggestions on that path as well.
[EDIT]
I finally changed to java... it was impossible with php...
Check your php.ini file and make sure it has the DB2 extension enabled. http://www.php.net/manual/en/install.pecl.php
Try this link:
http://www.theregister.co.uk/2006/08/09/db2_udb_part2/
Deals with:
Installing the PHP DB2 extension,
Creating a connection,
Obtaining a result set
Also gives as an alternative the PDO option.
But as for DB2 on the AS400, am not sure if something still needs to be installed on the
AS400 for this to work?
Anyway, have used the ODBC Client Access with no problems at all. What difficulty did you run into?

Using SQL Server in Cake PHP: PHP SQL Server interface is not installed

I inherited an old Cakephp site that was using adodb as a driver to connect to an MSSQL database and it turns out this is no longer supported in the new version of cake (1.3, we are in 1.2) so I'm trying to change the driver so I can upgrade. We're using IIS and a sql server 2005 database on a different server, php 5.2.17. However using driver "mssql" gives me the following errors:
PHP SQL Server interface is not installed. For troubleshooting information, see http://php.net/mssql/
Call to undefined function mssql_min_message_severity()
The top error leads me to a page regarding the old php_mssql.dll, which according to this question: ( CakePHP: error when trying to use mssql datasource ) will become a problem when I switch to PHP 5.3 so I'm trying to use the php_sqlsrv*.dll for my php version but I still get the error. Could never get the mssql.dll one to work either. I do however see "sqlsrv support enable" in phpinfo.php and the whole sqlsrv section is intact there.
In cake php I'm using "driver => 'mssql'", is this the correct driver for the new sqlsrv dll? Is there something I'm missing? For kicks I tried 'driver' => 'sqlsrv', that fixes the php SQL Server interface error but I still get
"Fatal error: Call to undefined function sqlsrv_min_message_severity() in C:\Inetpub\wwwroot\riverstone-dev\www\cake\libs\model\datasources\dbo\dbo_sqlsrv.php on line 107"
Installing the latest SQL Native Client set from Microsoft and reenabling the extension in PHP has worked, albeit on a different server. Please try the drivers below if having a similar problem:
http://www.microsoft.com/download/en/details.aspx?id=20098

Categories