SqlBindObject(sqlquery, string, object)

From NWN Lexicon
Revision as of 00:00, 24 August 2020 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.

Bind an object to a named parameter of the given prepared query.

void SqlBindString(
    sqlquery sqlQuery,
    string sParam,
    object oObject
);

Parameters

sqlQuery
An already prepared SQL query
sParam
Parameter referenced in sqlQuery to bind
oObject
Object to serialise and bind

Description

Bind a object to a named parameter of the given prepared query.

Objects are serialized, NOT stored as a reference! This is identical to StoreCampaignObject and all caveats of that apply to this.

Currently supported object types: Creatures, Items, Placeables, Waypoints, Stores, Doors, Triggers

Presumably like CopyObject if oObject is a player, it will serialise a "NPC version" of them.

Remarks

This allows much easier inputting of variables into a pre-prepared query, removing the need for a large amount of string parsing to simply update certain variables of a query.

You utilise this by defining the parameter to alter in the prepared query, and reference it as the sParam part.

See SqlBindString for how you can store an object reference using ObjectToString rather than the entire object itself.

Version

This function was added in 1.80.8193.14 of NWN:EE.

Example

    sqlquery v = SqlPrepareQueryObject(GetModule(), "insert into test (col) values (@myint);");
    object oNPC = GetObjectByTag("NPC");
    SqlBindObject(v, "@myint", oNPC);
    SqlStep(v);

See Also

functions:

SqlPrepareQueryCampaign SqlPrepareQueryObject SqlBindInt SqlBindFloat SqlBindString SqlBindVector