pdo

Where to rollback a transaction in PDO ?

my problem is , i have a database design from this link http://stackoverflow.com/questions/3305825/is-my-database-overdesigned edit* ok maybe useing transaction ? but where should i put the rollback if it fails ? $dbConnect->beginTransaction(); $RegisterInsert = $dbConnect->prepare("INSERT INTO companies ( `name`, `address`, `ema...

When did PDO SQLite come into being?

What is the first version of PHP that started supporting the PDO_SQLite driver? I know it was PHP 5 that brought PDO into the core so I'm assuming that PDO_SQLite must have been in version 5.0 also... I want to know what requirements I'll need for a script using PDO_SQLite. ...

How can realise in PHP PDO WHERE IN statment

Params: $params = 2826558; # Necessary Object $params = array(2826558,2677805,2636005); # NULL Execution code: $data = $this->DQL_selectAllByCampaign_id() ->execute( array($params) ) ->fetchAll(); var_dump( $data ); SQL Query: $this->DQL_selectAllByCampaign_id = $th...

Help with a joined query (MySQL)

Hello can anybody see why this query fails? SELECT A.idAd, A.ads_in_Cat, A.title, A.currency, A.price, A.in_dpt, A.description, A.featured FROM ads A LEFT JOIN featured F ON F.ad = A.idAd INNER JOIN dept D ON D.id_dept = A.in_dpt INNER JOIN sub_cat_ad S ON S.id_sub_cat = A.ads_in_Cat INNER JOIN cat_ad C ON C.idCat_ad = S.from_cat_ad ...

PHP - PDO return escaping slash, how to remove it?

I am doing some select with PDO object, but after fetch result, I got string with escaped ' to \', how can I disable that? ...

Foreach loop brings to Fatal error: Call to a member function bindParam() on a non-object

Hi there, That's the first time i get an error like this one, let me explain : Here is my code : function printSiteIndexedItems($co, $id){ global $allSections; foreach($allSections as $aSection => $aSectionName){ $tr = $co->prepare("SELECT COUNT(id) FROM ". $aSection ." WHERE site=:id AND valide=1"); $tr->bindParam(':id', $i...

PDO select query error

I am trying to run this simple SELECT query using PDO::MySQL, but it does not return a value, as you can see from the dump $row returns false, which means there was an error. The database connection works, as I'm writing to the database a few lines further down Sql query is correct Can someone see the bug in this code? If you can I'd ...

Extending PDO Statement Class

Is it possible to extend PHP PDO statement class to add custom methods to it? This would be different from extending the base PDO class. If so, how would one go about doing it since the statement class is only returned when running queries through the PDO class? ...

PDO maturity in PHP 5.2.13

How mature is PDO for PHP 5.2.13 for a serious project? (By serious I mean a script that is going to be sold and deployed in different platforms and environments. Something not serious would be for testing or developing, in this case) Currently, most host companies are running PHP 5.2.13 and adoption for 5.3.x seems too far away... S...

getDefaultAdapter Zend framework 1.10

I have next settings in application.ini resources.db.adapter = PDO_MYSQL resources.db.params.host = localhost resources.db.params.username = some resources.db.params.password = somepass resources.db.params.dbname = name resources.db.isDefaultTableAdapter = true have 2 similar models Zend_db_table_Abstract in first model i use $db = ...

Character encoding issue with PDO_ODBC

When accessing a Microsoft SQL Database from PHP using PDO_ODBC with the following code, I have an encoding issue. When outputed the text from the DB is garbled. $dsn = "odbc:DRIVER={SQL Server};SERVER=$hostname;DATABASE=$database;charset=UTF-8"; $pdo = new PDO($dsn,$username,$password); $sql = "SELECT text FROM atable"; $result = $PDO-...

Is this query injection proof?

I am using PDO to talk to my database, and I wonder if casting a type like this $dbh->query("SELECT * FROM recipes WHERE id=".(int)$id); is sufficient to prevent sql injection? In this case $id is always an integer. I also wonder what would be a good way to prevent an injection in this kind of statement if the variable was a string. ...

PDO begintransaction vs MySQL db lock

what is the advantage of using pdo begintransaction, is this and mysql db lock are same? I have a table with urls and status column, whenever my application loads 10 urls I need to update the status column as loaded. This application will be accessed by couple of users simultaneously, how would I prevent user B from loading the same url...

PHP ADOdb/PDO equivalent of Perl DBI quote_identifier?

At my current job, the standard practice has been to use mysql_query() and friends directly. When constructing large queries, since our standard deployment is on MySQL, table names just get inserted and surrounded by backticks (partial, fake example): $sql .= "from `$tablename`"; I'm trying to get away from MySQL-ism's, and as part o...

PDO refuses to switch between multiple Databases!

Please I am very new to PDO, rather a novice at PHP as well. I am currently working on a project that involves connections to many databases: MySQL, MSSQL and Oracle. So I am using the class below, with PDO, for my connection. The class code is below. class db { private static $objInstance; /* * Class Constructor - Create a new data...

How to execute an insert stored procedure using PDO and PHP form variables?

Good Evening All, I'm very new to PDO prepared statements and need some guidance/gentle nudges. I've created the following MySQL stored procedure: -- -------------------------------------------------------------------------------- -- Routine DDL -- -------------------------------------------------------------------------------- DELIMI...

PDO 'LIKE' query

Hi Folks. Since i'm new to using PDO and running into a problem when deviating from a simple select from query, i figured i'd best ask around here. The code: $sDbase = str_replace('`', '', $modx->db->config['dbase']); $oPdo = new PDO("mysql:host=localhost;dbname=" . $sDbase . ";", $modx->db->config['user'], $modx->db->config['pas...

Print_r and foreach giving different results

I have a pdo function that fetches usernames and user ids from the database. When I run the function i get different results. print_r gives Array ( [ID] => 58 [username] => abdullatif ) and foreach gives me 5-5a-a There is one row that matches the pdo query in the database. public function getUserCredentials($userName, $passwo...

Magento loadByAttribute fails on question marks

Trying to load a product by it's name ("What are Tests?") fails even though the product exists. $product = Mage::getModel('catalog/product')->loadByAttribute('name', 'What are Tests?'); It works for any other name though. As Magento ultimately goes through PDO, would the "?" in the name be interpreted as a parameter and as I'm not pa...

Best practices for a PDO class?

I want to create a PDO class for handling data base connections. Here is what I have: require('php/packages/store/store_db_settings.php'); class store_pdo { private $DBH; // Data Base Handler function __construct() { $DBH = new PDO(DB_DSN,DB_USER,DB_PASSWORD); } public function getHandler() { ...