Tag Archives: pdo

php cannot check if a PDO result is empty using empty() returns FATAL ERROR

I want to check whether my prepared query has returned empty or not without having to go into a loop. This is the code I have tried using:

if(empty($pQuery1->fetch(PDO::FETCH_ASSOC))){}

When I try this I get the error:
Fatal error: Can't … Continue reading

Tagged , , , | Leave a comment

PDO : How different is mysql from postgresql

I want to use Mysql on my local and PostgreSQL on production server. How difficult is it. I am mysql novice and have no idea on PostgreSQL. I will be using just crud with joins. My coding is in PHP… Continue reading

Tagged , , , | Leave a comment

Automatically Catch Exceptions for PDO in PHP

Evening,
I am currently handling PDO exceptions like this:

try{
$db = Db::connect();
$query = $db->prepare( "SELECT * FROM table;" );
$query->execute();
}
catch( PDOException $e ) { error( 'MySQL error: ' . $e->getMessage(), __FILE__, __LINE__ ); }

My handling Continue reading

Tagged , , | Leave a comment

PDO database for arabic characters

i want to insert arabic characters to database using pdo with php
but i got these charectors in database

الجامع &#1575

and when i put

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

the result was

   ??????????

i make the collection of the collom Continue reading

Tagged , , , , | Leave a comment

PHP PDO Params – Empty strings in $data array cause query to fail

I have a PDO issue with PHP 5.3. I am running MaxDB 7.8 for my database – if you haven’t heard of that, you’re not alone. It’s an open-source enterprise database that is connected with MySQL on paper, but is… Continue reading

Tagged , , | Leave a comment

In PHP + PDO fetch the details of the query last executed or fill the question marks in query with corresponding entries

I need to get the complete query with the filled values after the query got successfully executed, (basically I want the query string with the question marks in the query removed and get replaced with corresponding values) so that I… Continue reading

Tagged , | Leave a comment

How to check if column does not exist using PHP, PDO, MySQL?

In my application I have a generic query that applies to multiple users. There are instances where the table structure may differ between users. I have a query that I only want to apply to the users where the column… Continue reading

Tagged , , | Leave a comment

PDO: row name as index of result array

I have this “old-style” non-PDO MySQL query (the code isn’t tightened up, just to show exactly what I mean):

<?php
include('db_conn.php'); //Contains the connection info.

$category = 'cars';
$q = "SELECT * FROM `photos` WHERE `category` = '$category'";
$qResult = 

Continue reading

Tagged , , | 2 Comments

Necessary to increment PDO variables

I haven’t been able to find anything that explicitly answers this and have been wondering for a while. Sorry if it is a newbie question.
Do I have to increment or change my PDO variables in the following scenario. If… Continue reading

Tagged , | Leave a comment

Basic: CakePHP data not being saved nor validation working?

What I would like to know is a two part question.
Why is the validation not doing anything, and why won’t the data post to the database?
QuestionsController.php

public function index() {
    $this->set('questions', $this->Question->find('all'));
}

public function view($id = null) 

Continue reading

Tagged , , , | Leave a comment
20 pages