I know my SQL safety isn't up to par. I've read on this site that PHP PDO would be a good first step, and while I did take a look at the PDO Manual it's a bit daunting. Is there somewhere I can find a tutorial on the basics of using PDO rather then straight MySQL calls?
...
Hi
I have been given access to a CentOS5 machine by my client for their new site which uses Zend Framework.
phpinfo() states in Configure Command that PDO is disabled ('--disable-pdo'). How can enable it? Do I need to recompile PHP5 to enable it?
I have tried adding 'extension=pdo.so' in php.ini and restarting Apache, but this didn't...
I have a simple insert statement using PDO php class.
the 'id' column is identity (doy) with autoincrement.
$statement = $db->prepare('INSERT INTO demographics (id,location_id,male,ethnicity_id,birthyear) VALUES (:id,:location_id,:male,:ethnicity_id,:birthyear)');
$statement->bindParam(':id',$demo->id,PDO::PARAM_INT,4);
$statement->b...
I can't seem to get this to connect to the database so that I can run my prepared statement. Does anybody have an idea what I've forgotten?
private function check_credentials($plain_username, $password)
{
global $dbcon;
$ac = new ac();
$ac->dbconnect();
$userid = $dbcon->prepare('SELECT id FROM users WHERE username ...
Hi
I have the following PHP code doing a very simple select into a table.
$statement = $db->prepare("SELECT * FROM account WHERE fbid = :fbid");
$statement->bindParam(":fbid",$uid, PDO::PARAM_STR,45);
$out = $statement->execute();
print_r($out) // 1;
//$out = $statement->execute(array(':fbid' => $uid)); // also doesn't work
$row = $sta...
I really have NO idea of what to do with this now, i have been staring at it for hours, and reqritten it.. i can't get it to work!.
require_once("Abstracts/DBManager.php");
require_once("UI/UI.Package.php");
class BlogDBM extends DBManager
{
private $table = "blog_records";
function saveRecord($title,$url,$desc,$feedId,$pubDat...
Using PHP/PDO/MySQL is it possible to use a wildcard for the columns when a select is done on multiple tables and the returned array keys are fully qualified to avoid column name clash?
example:
SELECT * from table1, table2;
gives:
Array keys are 'table1.id', 'table2.id', 'table1.name' etc.
I tried "SELECT table1.*,table2.* ..." but...
I want to use pdo in my application, but before that I want to understand how internally
PDOStatement->fetch and PDOStatement->fetchAll.
For my application, I want to do something like "SELECT * FROM myTable" and insert into csv file and it has around 90000 rows of data.
My question is, if I use PDOStatement->fetch as I am using it ...
I'm having problems using params in the ORDER BY section of my SQL. It doesn't issue any warnings, but prints out nothing.
$order = 'columnName';
$direction = 'ASC';
$stmt = $db->prepare("SELECT field from table WHERE column = :my_param ORDER BY :order :direction");
$stmt->bindParam(':my_param', $is_live, PDO::PARAM_STR);
$stmt->bind...
I have a written a script in PHP that reads from data from a MySQL database. I am new to PHP and I have been using the PDO library. I have been developing on a Windows machine using the WAMP Server 2 and all has been working well. However, when I uploaded my script to the LINUX server where it will be used I get the following error when ...
I have a table of emails.
The last record in there for an auto increment id is 3780, which is a legit record. Any new record I now insert is being inserted right there.
However, in my logs I have the occasional:
Query FAIL: INSERT INTO mail.messages (timestamp_queue) VALUES (:time);
Array
(
[0] => 23000
[1] => 1062
[2] =>...
The company I work for currently uses some basic functions to abstract the OCI libraries as a means for DB connectivity. We're considering switching to PHP's PDO object, but from some quick searches, it looks like the Oracle driver is a bit less mature than the other PDO drivers. I would appreciate some pro/cons for PDO/Oracle from any...
Hello,
I've come upon a rather interesting thing, which I can't seem to figure out myself.
Everytime when executing a SQL statement which contains a '... AND ...' the result is empty.
Example:
echo('I have a user: ' . $email . $wachtwoord . '<br>');
$dbh = new PDO($dsn, $user, $password);
$sql = 'SELECT * FROM user WHERE email = :em...
Hi,
I try to use the SQL statement
SELECT * FROM table ORDER BY column
via an PDO-Object in PHP. Problem is, that I always get an error (Call to a member function fetchall() on a non-object - that means, the query did not return a PDO-object) when using the names of all columnname EXCEPT for ID. When I query
SELECT * FROM table ORDE...
I am trying to save data into a database using PDO. All columns save correctly with the exception of one. No matter what I try, I cannot get the data to go in.
myfunc($db, $data) {
echo $data; // <----- Outputs my data. example: 'jim jones'
$stmt = $db->prepare("CALL test(:id, :data, :ip, :expires)");
$stmt->bindParam(':id...
I am create a class which uses PDO to interact with MySQL. Can I create a new MySQL table using PDO?
...
I have no idea why my code is failing silently. PDO and PDO SQLite are confirmed loaded. Errors are turned on and OTHER errors display.
The SQLite file exists. Perms are set correctly. If I change the filename, PHP actually DOES create the file but still fails silently. No output or commands are excecuted after the "$dbh = new PDO(...
I'm experimenting with PHP's session_set_save_handler and I'd like to use a PDO connection to store session data.
I have this function as a callback for write actions:
function _write($id, $data) {
logger('_WRITE ' . $id . ' ' . $data);
try {
$access = time();
$sql = 'REPLACE INTO sessions SET id=:id, access=:ac...
I have defined a function in my Navigation model that executes a query, and I was wondering if there's a more "Zendy" way of generating/executing the query. The query I'm using was proposed by Bill Karwin on another thread here for setting arbitrary record order. I tried using a prepared statement, but the values in the SIGN() function...
Hi,
I'm using PDO for connect to the database in a system where I want implement memcached.
I don't know what keys use for caching the results because I can't get the string of the final query with PDO (because the prepared statements).
Any good idea for resolve this?
Thanks in advance.
...