pdo

PDO - SQL Server RESTORE DATABASE query - wait until finished?

I am using PDO to restore a SQL Server 2008 database, and issuing a query to restore the database like this: $pdo->exec('RESTORE DATABASE [blah] FROM DISK = \'c:\blah.bak\' WITH NOUNLOAD'); But the exec() returns before the database is fully restored, is there any way I can make it wait? If not, is there a query I can run in a loop wi...

limit in php PDO?

Hi, as people suggested me, I started using PDO library instead of Creole. Most of things are almost same as Creole, but I cannot find a function to set limit. I do not think that I should include limit statement in my query string since mssql and mysql do not share same syntax. please advise me. ...

PHP PDO: Can I bind an array to an IN() condition?

I'm curious to know if it's possible to bind an array of values to a placeholder using PDO. The use case here is attempting to pass an array of values for use with an IN() condition. I'm not very good at explaining, so here's some psuedocode to demonstrate... I'd like to be able to do something like this: <?php $ids=array(1,2,3,7,8,9);...

How to enable the PDO driver for sqlite3 in php?

Goodeve, My SQLite is version 3.4.0 However my phpinfo's PDO support for SQLitev3 is not enabled/listed How can I enable it? I installed my web server via XAMPP. ...

Concurrency Problem

Hello, I'm having what seems to be a concurrency problem while using MySQL and PHP + Propel 1.3. Below is a small example of the "save" method of a Propel object. public function save(PropelPDO $con = null) { $con = Propel::getConnection(); try { $con->beginTransaction(); sleep(3); // ignore this, used for testi...

Can you return multiple result sets using PDO and PostgreSQL?

I would like to group multiple queries into a single function that lives in PostgreSQL. The function will be queried using PDO. The function is: CREATE OR REPLACE FUNCTION "test_multipe_refcursor"() RETURNS SETOF refcursor AS $BODY$ DECLARE parentRC refcursor; childRC refcursor; BEGIN open parentRC FOR SELECT * FROM parent;...

correct usage of Zend_Db

Hi, I'm currently using the Zend_Db class to manage my database connections. I had a few questions about it. Does it manage opening connections smartly? (eg, I have a connection already open, does it know to take use of it - or do I have to constantly check if theres' already an open connection before I open a new one?) I use the foll...

PDO Stored Procedure return value

Hey I'm working with a SQL Server stored procedure that returns error codes; here is a very simple snippet of the SP. DECLARE @ret int BEGIN SET @ret = 1 RETURN @ret END I can get the return value with the mssql extension using: mssql_bind($proc, "RETVAL", &$return, SQLINT2); However, I can't figure out how to access the return va...

php_pdo.dll and php_xsl.dll

Can these two items work together? php_pdo.dll and php_xsl.dll. I have a php server and it currently hosts a couple sites - one of which requires the php_xsl.dll to work. I am trying to install Piwik, but it says it needs php_pdo.dll and php_pdo_mysql.dll - whenever I add these to the php.ini file, it crashes both the piwiki site and ...

Is there a way to force PHP into waiting until MySQL is finished with a transaction?

I'll admit I'm not 100 % on the inner workings of PDO and MySQL, so I'll give an example to make my question clearer. I'm making a rather crude browser based strategy game, because I think it's a fun way to learn PHP and databases. I was bug-testing the battle script when I came across a rather unexpected bug. I use Cron Jobs to call a ...

PHP + PDO/MySQL: how to automatically clip strings to the proper length on insert

I have a table with various VARCHAR fields in MySQL. I would like to insert some user data from a form via PHP. Obviously if I know the field lengths in PHP, I can limit the data length there with substr(). But that sort of violates DRY (field length stored in MySQL and as a constant in my PHP script). Is there a way for me to configure ...

PHP + PDO/MySQL: how to automatically query to find out VARCHAR field lengths?

is there a way to use PHP+PDO to query a MySQL database and find out the column widths of some VARCHAR fields? I don't want to hardcode them into my PHP file if possible. (purpose: determine maximum lengths of strings to be either inserted into these columns, or compared against existing data in the columns.) ...

PHP - PDO SQLite3 Prepared Statements

I'm trying to use prepared statements in a PHP script that accesses an SQLite3 database using PDO. The normal version of this query works as expected: $q1 = "SELECT COUNT(*) FROM fruits WHERE name='apple'"; echo $db->query($q1)->fetchColumn(); However, my prepared statement version outputs nothing. $q2 = "SELECT COUNT(*) FROM fruits...

CANopen - Fastest rate at which PDOs are received

Assuming highest baud rate, what is the highest rate at which PDOs are received? ...

Do SQL connections opened with PDO in PHP have to be closed

When I open a MySQL connection in PHP with just PHP's built-in MySQL functions, I do the following: $link = mysql_connect($servername,$username,$password); mysql_select_db($dbname); //queries etc. mysql_close($link); When I open a connection with PDO, it looks like this: $link = new PDO("mysql:dbname=$dbname;host=$servername",$userna...

How can I display the full text of a query created by PDO?

I'm creating a SQL query with PDO in PHP. Unfortunately, there seems to be an error in my query. I've tried $query->errorInfo(), but that only gives me a little bit of the error message ("There is an error in your syntax near..."). How can I display the entire query that PDO is passing to my database? TIA. ...

PHP PDO prepared query won't return results from for loop

Hi, I have the following code: $link = new PDO("mysql:dbname=$databasename;host=127.0.0.1",$username,$password); $query = $link->prepare("SELECT * FROM index WHERE sbeid=:idvar"); for($j = 1; $j < count($array); $j++) { if($array[$j][16] == "TRUE" || $array[$j][16] == "FALSE") { $paramforquery = $array[$j][25]; ...

PHP PDO prepared query refuses to execute properly - escaping problem?

Hi, I'm having a problem with a query prepared in PHP with PDO. The code: $link = new PDO("mysql:dbname=$dbname;host=127.0.0.1",$username,$password); $link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $query = $link->prepare("SELECT locality_name FROM :passedday GROUP BY locality_name ORDER BY locality_name DESC"); $query...

PDO wrong date binding

Hi there, I'm querying a mssql 2008 database via odbc and stubled upon a strange behaviour. The following code is used... $datefrom = "2009-06-01"; $dateto = "2009-07-01"; $clientno = "01"; $sth = $db->prepare("select count(*) from tbl WHERE v_valid_from <= ? and valid_from <= ? and (v_invalid_from >= ?) and (valid_to >= ? or valid_to...

How to check if PDO support is enabled in my Apache Installation?

I am using a shared hosting through CIPL.in. They use cpanel. I am trying to deploy a ZEND app on my website. However it keeps giving the error. An error occurred Application error Exception information: Message: The PDO extension is required for this adapter but the extension is not loaded Stack trace: #0 /home/cubeeeco/worminc/libr...