pdo

PDO PHP query against Teradata using ODBC connect string returns no data from 5th column onwards

I'm using PDO to extract data from Teradata, using an ODBC connect string. The query returns the correct number of rows but column 5 onwards is blank (as compared to using the same query with the PHP ODBC library) Column 5 happens to be a varchar(400) field and I've read that PDO had bugs in the past with varchar columns > 255 in lengt...

Handling MySQL Backticks When Switching DB engines using PHP's PDO Interface

I'm currently working on a PHP application that uses a MySQL database for its backend All of my queries contain backticks to escape the field names. This is so I can have fields like "password" in a query without causing issues (see example) I know that backticks are not universal between relational-database engines (SQLite uses a doubl...

PDO with "WHERE... IN" queries

I'm reworking some PHP code to use PDO for the database access, but I'm running into a problem with a "WHERE... IN" query. I'm trying to delete some things from a database, based on which items on a form are checked. The length and content of the list will vary, but for this example, imagine that it's this: $idlist = '260,201,221,216,2...

PDO::PARAM for dates?

Hi, does exist some PDO::PARAM_??? which can be used for dates or timestamps? $sql = "UPDATE my_table SET current_date = :date WHERE id = 43"; $statement = $pdo->prepare ($sql); $statement->bindParam (":date", strtotime (date ("Y-m-d H:i:s")), PDO::PARAM_STR); $statement->execute (); ...

PHP PDO Related: Update SQL Statement not Updating the content of Database

I am trying to implement update statement using prepared statement in php script but it appears that it is not update record in the database and am not sure why and so would appreciate if you can share some insights. Code $query = "UPDATE DatTable SET DF_PARTY_ID = :party_id, DF_PARTY_CODE = :party_code, DF_CONNECT...

Count the sum of a column values in a SELECT statement

Hi, I have a table where I should count if an user has reached a number of penalities like 3, so if the user reach or surpass 3 points, he's banned: table_warnings - id - user_id - warning - warning_date id user_id warning warning_date 1 5478 1 2010-02-25 12:59:00 2 5478 1 2010-02-28 08...

ODBC query on MS SQL Server returning first 255 characters only in PHP PDO (FreeTDS)

I'm currently trying to pull some data from a SQL Server database view that we have restricted access to from our Linux web server. We don't need to edit the data just display it in a webpage. It all looks fine until we try to output and only get the first 255 characters of a text field. Does anyone know if this is a problem with usin...

How to debug PDO database queries?

Before moving to PDO, I created SQL queries in PHP by concatenating strings. If I got database syntax error, I could just echo the final SQL query string, try it myself on the database, and tweak it until I fixed the error, then put that back into the code. Prepared PDO statements are faster and better and safer, but one thing bothers m...

php pdo: it it possbile to have a DBMS agnostic 'describe table' ?

Hiya. I have a script that parse the database and create php classes to work with that db. (zend-db-model-generator). is there a way to in php to have a DBMS agonstic commands so on each type of db it will return the table structure ? so it doesn't matter if i use the pdo driver once for mysql and once for postgresql, it will still ret...

How to avoid this PDO exception: Cannot execute queries while other unbuffered queries are active

Hi, I'd like to print a simple table in my page with 3 columns, building name, tags and architecture style. If I try to retrieve the list of building names and arch. styles there is no problem: SELECT buildings.name, arch_styles.style_name FROM buildings INNER JOIN buildings_arch_styles ON buildings.id = buildings_arch_styles.building_i...

Newbie question about pdo

How to rewrite this in pdo: $con = mysql_connect("localhost:".$LOCAL_DB_PORT, $LOCAL_DB_USER, $LOCAL_DB_PASS); mysql_select_db("xnews", $con); mysql_query("set names utf8", $con); Thanks in advance! ...

Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' with pdo

$db = new PDO('mysql:dbname=xnews;host=localhost;port=' . $LOCAL_DB_PORT, $LOCAL_DB_USER, $LOCAL_DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'") ); reports: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' Is it renamed? ...

PDO: Unable to create SQLite database in memory

Trying to learn a bit about PDO and is going through this tutorial. It has the following snippet of code: <?php try { $db = new PDO('sqlite::memory'); echo "SQLite created in memory."; } catch(PDOException $e) { echo $e->getMessage(); } When I run this I get the following exception message: SQLSTATE[HY000] [14] unabl...

PDO: Transactions don't roll back?

I am going through this tutorial about PDO and have come to the point about transactions. Skipping the connection parts, I have this php code: try { $db->beginTransaction(); $db->exec('DROP TABLE IF EXISTS animals'); $db->exec('CREATE TABLE animals (' .'animal_id MEDIUMINT(8) NOT NULL AUTO_INCREMENT PRIMARY KEY,' ...

PDO Parameterized Query - Reuse named placeholders?

In essence, I have a value that I have to call a couple times in my SQL query. Thus, is it possible to reuse the same named placeholder in the statement e.g. SELECT :Param FROM Table WHERE Column = :Param, then simply bindValue(":Param"), and have the value be there for both :Params? ...

PDO Prepare statement not processing parameters

I've exhausted all efforts at what appears to be a trivial problem, but gotten nowhere. There is a simple Prepare statement: $qry = $core->db->prepare("SELECT * FROM users WHERE email = '?'"); $qry->execute(array('[email protected]')); However, no rows are returned. Running the query with the parameters hardcoded into the query resul...

PDO fails to prepare a statement with over 13 placeholders

Hello, this is the code I'm using: self::$DB->prepare($query, $types); when the $query and types are: //$query UPDATE Permisos SET empleado_id = ?, agregar_mensaje = ?, borrar_mensaje = ?, agregar_noticia = ?, borrar_noticia = ?, agregar_documento = ?, borra...

Preparing a MySQL INSERT/UPDATE statement with DEFAULT values

Quoting MySQL INSERT manual - same goes for UPDATE: Use the keyword DEFAULT to set a column explicitly to its default value. This makes it easier to write INSERT statements that assign values to all but a few columns, because it enables you to avoid writing an incomplete VALUES list that does not include a value for each column in t...

Do I really need bindParam?

Hi there! I'm trying to do a little PDO CRUD to learn some PDO. I have a question about bindParam. Here's my update method right now: public static function update($conditions = array(), $data = array(), $table = '') { self::instance(); // Late static bindings (PHP 5.3) $table = ($table === '') ? self::table() : $table; ...

Is this pdo bug fixed now?

Note that you can specify a port number with "port=####", but this port number will be ignored if the host is localhost. If you want to connect to a local port other than the default, use host=127.0.0.1 instead of localhost. Quoted from this page,has anyone verified if it has been fixed? ...