Re: [PHP-DB] PDO ?

2013-01-15 Thread Kapu®

On 15. 1. 2013 18:25, Jim Giner wrote:

Doing some conversion - looking for a solution.

Currently I do something like this:

while (list($var1,$var2) = mysql_fetch_array($qrslts))
{
handle the vars
}

Is there something in the PDO functions that emulates this same 
ability?  Some of my uses of the sql syntax have many more vars and I'm
trying to avoid having to move the fetch-ed fields one at a time to 
vars that I wish to use.

I already tried:

list($var1,$var2) = $qrslts-fetch(PDO::FETCH_ASSOC);

this does not populate the vars.


Hi,

using PDO::FETCH_NUM instead PDO::FETCH_ASSOC should do the job.

Kapu

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] auto_increment

2010-09-07 Thread Kapu

 You are missing a semicolon after the first alter statement.

Kapu

On 7. 9. 2010 18:05, Ron Piggott wrote:

I am receiving the following error Adriano:

SQL query:

ALTER TABLE `stats` DROP `visits` CREATE TABLE `stats2` LIKE `stats` ;

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'CREATE TABLE `stats2` LIKE `stats`' at line 2

The complete commands were:

ALTER TABLE `stats` DROP `visits`
CREATE TABLE `stats2` LIKE `stats`;
ALTER TABLE `stats2` ADD COLUMN `visits` INT( 25 ) NOT NULL
AUTO_INCREMENT, ADD PRIMARY KEY(`visits`) FIRST;
INSERT INTO `stats2` SELECT *, 0 FROM `stats` ORDER BY `initial_access`;

I don't understand the error, your way of creating a table is new to me.
Did something small get missed?

Ron




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php