Skip to main content

All Questions

Tagged with
1 vote
2 answers
1k views

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

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 < ...
5 votes
3 answers
7k views

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 ...
1 vote
1 answer
1k views

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

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 ...
0 votes
1 answer
5k views

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='...
3 votes
2 answers
1k views

Concurrency Problem

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) ...
0 votes
2 answers
4k views

Cant the prepared statement be used throught the transaction, from php?

I work on a LAPP environment (linux apache postgresql php), and i'm just triyn to find out how to use the prepared statement within the transaction (if is possible). I hope code will explain better ...
0 votes
1 answer
1k views

User defined MySQL function not accessible with PHP PDO connection

I've got a trivial MySQL function: DELIMITER $$ DROP FUNCTION IF EXISTS `mydb`.`CALC` $$ CREATE FUNCTION `mydb`.`CALC_IT`(Flag VARCHAR(1), One FLOAT, Other FLOAT) RETURNS FLOAT BEGIN IF One IS ...
4 votes
6 answers
2k views

Is it better to use a prepared Select statement when you are only doing one select?

I am currently writing a CRUD class in PHP using PDO. I like the security that prepared statements provide, but I have heard that they also prevent databases like mysql from using the queryCache. Is ...
5 votes
5 answers
5k views

Is this wrapper for PDO 'good code' ? Are there any potential problems?

I built this class to work with PDO, to make SQL queries 'easier' and less to worry about. Here are my thoughts Should it be more like class DB extends PDO? Is the query method too big? Should it ...
0 votes
4 answers
761 views

Does PHP's Oracle PDO hang on DELETE?

This hangs in Php (5.2.6-Win32 + Oracle10g) is it a bug, or I'm doing something fundamentally wrong? try { $conn = new PDO($DB,$USER,$PASSWORD); $conn->setAttribute( PDO::ATTR_ERRMODE, PDO:...
1 vote
3 answers
147 views

What databases used with PHP share the same (or most) of the SQL syntax?

I've read that although SQL is meant to be standardised, it is implemented different etc with different databases. I have only ever used MySQL for databases. What I would like to know is what other ...
1 vote
1 answer
590 views

Database return records as object or array?

Which is the better alternative? I've noticed PDO let's you return as an array or an object. I've always used arrays when using my old functions (mysql_fetch_assoc()) but I've just written a wrapper ...
9 votes
1 answer
30k views

How to change character encoding of a PDO/SQLite connection in PHP?

I'm having a little problem with a php-gtk app that keeps running into non-utf8 strings, I had found that the problem is in the database connection, even when the database is supposed to be in UTF-8. ...
1 vote
2 answers
1k views

PDO query problem

I am updating some code from the old mysql_* functions to PDO. It connects without a problem, runs the query without a problem, but the resultset is empty. PDO::query() is supposed to return a ...
1 vote
4 answers
2k views

Named parameters, caching and PDO

If i have a parameterized SQL statement like this: SELECT * FROM table WHERE my_field = :field_value Does anyone know if PDO will recognize this(see below) as the same SQL statement and use the ...

15 30 50 per page