Re: PHP Bug #6275 Parameter markers
| From: | jlim at natsoft dot com dot my | Date: | Wed, 03 Jan 2001 02:03:09 +0000 |
| Subject: | Re: PHP Bug #6275 Parameter markers | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-42774@lists.php.net to get a copy of this message | ||
Hi Dan,
This is part of the ODBC standard. The question mark variables are bound to
the array variables.
See http://msdn.microsoft.com/library/psdk/sql/od_6_015_3x83.htm
Using Statement Parameters
A parameter is a variable in an SQL statement that can enable an ODBC
application to:
Efficientlyprovide values for columns in a table.
Enhanceuser interaction in constructing query criteria.
Managetext, ntext, and image data and Microsoft® SQL Server-specific C
data types.
For example, a parts table has columns named partid, description, and
price. To add a part without parameters requires constructing an SQL
statement such as:
INSERT INTO Parts (PartID, Description, Price) VALUES (2100, 'Drive shaft',
50.00)
Although this statement is acceptable for inserting one row with a known
set of values, it is awkward if an application is required to insert
several rows. ODBC addresses this by allowing an application to replace any
data value in an SQL statement by a parameter maker, which is denoted by a
question mark (?). In the following example, three data values are replaced
with parameter markers:
INSERT INTO Parts (PartID, Description, Price) VALUES (?, ?, ?)
The parameter markers are then bound to application variables. To insert a
new row, the application has only to set the values of the variables and
execute the statement. The driver then retrieves the current values of the
variables and sends them to the data source. If the statement will be
executed multiple times, the application can make the process even more
efficient by preparing the statement.
Each parameter marker is referenced by its ordinal number, assigned to the
parameters from left to right. The leftmost parameter marker in an SQL
statement has an ordinal value of 1, the next one is ordinal 2, and so on.
Regards, John
> Hello!
>
>
> I was looking into your bug report and have a question on it. In your
> sample code you do the following lines:
>
> $stmt = odbc_prepare($conn,"insert into ADOXYZ (id,firstname,lastname)
> values (?,?,?)");
> if ($stmt) {
> print "Trying execute<br>";
> $stmt = odbc_execute($stmt,array(1,"John","Lim"));
> }
>
>
> What exactly are the values of (?,?,?) supposed to be? It looks to me
> like you are violating your table setup by trying to insert a char into an
> int (subatomic id in this case). Or are you tryinig to do a fuzzy-logic
> match (but to what I can't fathom)?
>
> Anyways if you could help I'll see if I can clear up your bug...
>
> --
> Dan Kalowsky "Tonight I think I'll walk alone,
> Worldgate Communications I'll find my soul as I go home."
> Software Engineer - TICS Group - Temptation
---
"Stressed spelled backwards is desserts."
jlim@natsoft.com.my NATSOFT MALAYSIA (60)3-706 1216
Visit this web site for Asian and local Internet news
http://webfeet.editthispage.com/
My PHP website:
http://php.weblogs.com/