Skip site navigation (1) Skip section navigation (2)

Uncertain about recoding prepared statements from MySQL toPostgreSQL

From: "G(dot) J(dot) Walsh" <gjwalsh(at)dscdirectionalservices(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Uncertain about recoding prepared statements from MySQL toPostgreSQL
Date: 2007-11-03 00:13:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Within a lengthy form script:

In MySQL, I had, by way of example,

$sql = 'INSERT INTO testee VALUES (? ? ? ? ?)';
$stmt = $dbcx->stmt_init();

In PostgreSQL, to accomplish the same thing, I would want to try:

$query = "INSERT INTO testee (protocode,service,sample,normid,proctored)
VALUES ($1,$2,$3,$4,$5)"; 
$result = pg_prepare($cnx,"newtestee",$query);

Have I got this synyax down correctly?

I presume the pg_execute provides the data type information (the 'sssss'
in the MySQL bind-param???

I have modified another field (not shown above) as being type TIMESTAMP
DEFAULT now(). I assume I would 'pass over' such fields were they to
appear in the above example. 

In MySQL the '?' placeholder in the INSERT was replaced with:

Thanks for the 'steer'. A few more coversions and I will develop a
rhythm of familiarity. For now, I want to avoid any bad habits and
faulty thinking. Its much more difficult to UNlearn than it is to learn
in the first place.



pgsql-novice by date

Next:From: normanDate: 2007-11-03 09:46:14
Subject: Populate a database with username and generate MD5 hash
Previous:From: Sean DavisDate: 2007-11-02 18:49:14
Subject: Unflatten array

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group