pdo

PDO mySql query not executing in for loop the second time up while calling

I have an issue, I'm looping threw a set of values and then creating a PDO mySql query with every loop, now the problem is the first query is executing and returning results, but the second upwards aren't returning results. If I manually execute the queries on the server they return results. This is weird, maybe I'm doing something wrong...

How to you insert into MySQL database and returns its id in PHP PDO?

Is there a way to insert into MySQL database using PHP PDO and return its id? Or I will just have to search fot its id after insertion? ...

MySQL match against - IN BOOLEAN MODE?

Hi there, I'm using PDO to execute a MATCH AGAINST query. The following returns nothing: SELECT title, author, isbn, MATCH(title, isbn) AGAINST (:term) AS score FROM books WHERE MATCH(title, isbn) AGAINST (:term) ORDER BY score DESC LIMIT 0,10 Where as this returns perfectly: SELECT title, author, isbn, MATCH(title, isbn) AGAINST ...

SQLSTATE[08004] [1040] Too many connections

i'm getting this error messages SQLSTATE[08004] [1040] Too many connections,i'm using pdo adapter...do i need to close connection...and how i do that ...

PDO: MySQL server has gone away

I have a script that does a lot of legwork nightly. It uses a PDO prepared statement that executes in a loop. The first few are running fine, but then I get to a point where they all fail with the error: "MySQL server has gone away". We run MySQL 5.0.77. PHP Version 5.2.12 The rest of the site runs fine. ...

PHP PDO search engine with relevancy

Hi, I'm desperately trying to create a relatively concise search engine with PHP, mySQL and PDO. I have a database of books, and I'm trying query a search against two of the fields. Here is what I have so far: "SELECT id, title, author, isbn, MATCH(title, isbn) AGAINST (:term) AS score FROM %sbooks WHERE MATCH(title, isbn) AGAINST (:te...

Get query back from PDO prepared statement

Is there a way to retrieve the query that was used to generate a PDO Prepared statement object? ...

PHP PDO bindValue in LIMIT

Here is a snapshot of my code: $fetchPictures = $PDO->prepare("SELECT * FROM pictures WHERE album = :albumId ORDER BY id ASC LIMIT :skip, :max"); $fetchPictures->bindValue(':albumId', $_GET['albumid'], PDO::PARAM_INT); if(isset($_GET['skip'])){ $fetchPictures->bindValue(':skip', trim($_GET['skip']), PDO::PARAM_INT); } else{ ...

Transaction rollback doesn't work

Hi all! I have made a database wrapper with extra functionality around the PDO system (yes, i know a wrapper around a wrapper, but it is just PDO with some extra functionality). But i have noticed a problem. The folowing doesn't work like it should be: <?php var_dump($db->beginTransaction()); $db->query(' INSERT INTO test (data) VA...

Is there a way to retrieve the DSN from PDO after it has been created?

Is there a way to extract the DSN from a PDO object after it has been created? I have a rather tricky refactoring job to do and so far my best candidate solution may necessitate getting this info out of a PDO constructed elsewhere. For example: <?php $pdo = new PDO("sqlite::memory"); $otherClass = new OtherClass(); $otherClass->setDbCo...

Get Number of Rows from a Select statement

Hello all, I have this: $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $username, $password); $sql = "SELECT * FROM this_table"; $stmt = $dbh->query($sql); //num of rows? How do I get the number of rows returned from that SELECT statement? Thanks all ...

Getting a PHP PDO connection from a mysql_connect()?

I have a legacy PHP/MySQL app that calls mysql_connect(). Tons of existing downstream code makes mysql_query() calls, either directly or through wrappers, using this connection. For new code that I develop on the app, I would like to start using PDO. If I make a PDO connection using the same host/user/pass/dbname credentials, might I b...

Yii Framework/PDO getting error CDbCommand failed to execute the SQL statement: SQLSTATE[42000]

I'm trying to insert some data into a table using the Yii Framework together with the PDO object and get the following error I'm building the query using this code $connection = CActiveRecord::getDbConnection(); $sql="INSERT INTO sms_logs (to, from, message,error_code,date_send) VALUES (:to,:from,:message,:error_code,:date_sen...

How do I enable PDO using CentOS?

When outputting phpinfo(); I can see that PDO is set to '--disable-pdo' in the Configure Command section. How can I enable this using SSH? ...

PHP ORM with support for SQL Server 2005

I have been looking around the current options (and related SO questions) regarding PHP ORM solutions, however I have a couple of unique requirements: I am running PHP on Windows Server 2003 I need to interface with SQL Server 2005 I can't seem to find a simple answer from the PHP ORM solutions out there as to which (if any) support ...

Is MySQL converting UTF-8 characters in my query (not the results), stripping accents?

I've some records in a DB where one of the VARCHAR fields may contain accented letters. If I do the following query using the CLI MySQL client I get 1 row returned, which is correct: SELECT site_id, site_name FROM tbl_site WHERE site_name LIKE '%ém%' However, using some PHP (PDO) to do the same query returns all the rows that contain ...

A question about query result judgement in PHP and MySQL

Code as follows: $db = DatabaseService::getInstance(); //get a database handle,base on pdo $sql = "select * from authusers where ssouid = '".$ssouid."' order by regtime"; $res = $db->query($sql); if($res && $res->fetch()) // here is the Problem line { //do something } else { //raise some exception } In the problem line,I wa...

Facing problem working with PDO for mySQL

while using the following constructor $this->pdo = new PDO ($this->source, $this->username, $this->password); if I do not have any password then should I pass a NuLL value for creating a new instance of PDO? ...

How do I make my database connection secure?

I'm currently working on a website for my church's college group, and am started to get a little worried about the security of what I'm writing. For instance, I use this function: function dbConnect() { global $dbcon; $dbInfo['server'] = "localhost"; $dbInfo['database'] = "users"; $dbInfo['username'] = "root"; $dbInfo['pas...

Need help converting a script from PDO to Mysql

Im trying to convert this script, in my Zend program. http://github.com/jackmoore/colorrating/raw/master/rating/rating.php <?php class rating{ public $average = 0; public $votes; public $status; public $table; private $path; function __construct($table){ try{ $pathinfo = pathinfo(__FILE__); $this->path = realpath($pathi...