From 4b78404c20490a615459267426ce9e6737bf4485 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 14 Jul 2006 09:20:45 +0000 Subject: Moving files. --- .../pages/Manual/InlineParameterMaps.page | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 demos/sqlmap/protected/pages/Manual/InlineParameterMaps.page (limited to 'demos/sqlmap/protected/pages/Manual/InlineParameterMaps.page') diff --git a/demos/sqlmap/protected/pages/Manual/InlineParameterMaps.page b/demos/sqlmap/protected/pages/Manual/InlineParameterMaps.page new file mode 100644 index 00000000..3bfa4ceb --- /dev/null +++ b/demos/sqlmap/protected/pages/Manual/InlineParameterMaps.page @@ -0,0 +1,102 @@ + +

Inline Parameter Maps

+ +

If you prefer to use inline parameters instead of parameter maps, you can add +extra type information inline too. The inline parameter map syntax lets you +embed the property name, the property type, the column type, and a null value +replacement into a parametrized SQL statement. The next four examples shows +statements written with inline parameters.

+ + + + insert into PRODUCT (PRD_ID, PRD_DESCRIPTION) + values (#id#, #description#) + + + +

The following example shows how dbTypes can be declared inline.

+ + + + insert into PRODUCT (PRD_ID, PRD_DESCRIPTION) + values (#id, dbType=int#, #description, dbType=VarChar#) + + + +

The next example shows how dbTypes and null value replacements can also +be declared inline.

+ + + + insert into PRODUCT (PRD_ID, PRD_DESCRIPTION) + values (#id, dbType=int, nullValue=-999999#, #description, dbType=VarChar#) + + + +

A more complete example.

+ + + + update Accounts set + Account_FirstName = #FirstName#, + Account_LastName = #LastName#, + Account_Email = #EmailAddress,type=string,dbType=Varchar,nullValue=no_email@provided.com# + where + Account_ID = #Id# + + + +
Note: +Inline parameter maps are handy for small jobs, but when there are a lot of +type descriptors and null value replacements in a complex statement, an +industrial-strength, external parameterMap can be easier. +
+ +

Standard Type Parameters

+

In practice, you will find that many statements take a single parameter, often +an integer or a string. Rather than wrap a single value in another +object, you can use the standard library object (string, integer, et cetera) +as the parameter directly. The following example shows a statement using +a standard type parameter.

+ + + + select * from PRODUCT where PRD_ID = #value# + + + +

Assuming PRD_ID is a numeric type, when a call is made to this Mapped +Statement, a standard integer can be passed in. The #value# parameter +will be replaced with the value of the integer. The name value is simply +a placeholder, you can use another moniker of your choice. Result Maps support +primitive types as results as well.

+ +

For your convenience, the following PHP primitive types are supported.

+ + +

Array Type Parameters

+

You can also pass in a array as a parameter object. This would usually be a an +associative array. The following example shows a using +an array for a parameterClass.

+ + + + select * from PRODUCT + where PRD_CAT_ID = #catId# + and PRD_CODE = #code# + + + +

In the above example, notice that the SQL in this Mapped Statement +looks like any other. There is no difference in how the inline parameters are +used. If an associative array is passed, it must contain keys named catId +and code. The values referenced by those keys must be of the appropriate +type for the column, just as they would be if passed from a properties object.

+ + +
\ No newline at end of file -- cgit v1.2.3