Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Created October 23, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/f95ca7cae6bf47ef30741b67d446352c to your computer and use it in GitHub Desktop.
Save steveosoule/f95ca7cae6bf47ef30741b67d446352c to your computer and use it in GitHub Desktop.
Miva - Module Basic DB CRUD
<MvFUNCTION NAME = "CRUD_Example_Read" PARAMETERS = "example var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.example:id" VALUE = "{ CRUD_Examples.d.id }">
<MvASSIGN NAME = "l.example:foo" VALUE = "{ CRUD_Examples.d.foo }">
<MvASSIGN NAME = "l.example:bar" VALUE = "{ CRUD_Examples.d.bar }">
<MvASSIGN NAME = "l.example:baz" VALUE = "{ CRUD_Examples.d.baz }">
</MvFUNCTION>
<MvFUNCTION NAME = "CRUD_Example_Load" PARAMETERS = "id, example var" STANDARDOUTPUTLEVEL = "">
<MvOPENVIEW NAME = "Merchant"
VIEW = "CRUD_Examples"
QUERY = "{ 'SELECT * FROM ' $ g.Store_Table_Prefix $ 'CRUD_Examples
WHERE id = ?' }"
FIELDS = "l.id">
<MvIF EXPR = "{ g.MvOPENVIEW_Error }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'CRUD-EXAMPLES-00001', g.MvOPENVIEW_Error ) }">
</MvIF>
<MvIF EXPR = "{ CRUD_Examples.d.EOF }">
<MvCLOSEVIEW NAME = "Merchant" VIEW = "CRUD_Examples">
<MvFUNCTIONRETURN VALUE = 0>
</MvIF>
<MvEVAL EXPR = "{ CRUD_Example_Read( l.example ) }">
<MvCLOSEVIEW NAME = "Merchant" VIEW = "CRUD_Examples">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "CRUD_Example_Insert" PARAMETERS = "example var" STANDARDOUTPUTLEVEL = "">
<MvQUERY NAME = "Merchant"
QUERY = "{ 'INSERT INTO ' $ g.Store_Table_Prefix $ 'CRUD_Examples
( id, foo, bar, baz )
VALUES
( ?, ?, ?, ? )' }"
FIELDS = "l.example:id, l.example:foo, l.example:bar, l.example:baz">
<MvIF EXPR = "{ g.MvQUERY_Error }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'CRUD-EXAMPLES-00002', g.MvQUERY_Error ) }">
</MvIF>
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "CRUD_Example_Update" PARAMETERS = "example var" STANDARDOUTPUTLEVEL = "">
<MvQUERY NAME = "Merchant"
QUERY = "{ 'UPDATE ' $ g.Store_Table_Prefix $ 'CRUD_Examples
SET foo = ?,
bar = ?,
baz = ?
WHERE id = ?' }"
FIELDS = "l.example:foo, l.example:bar, l.example:baz, l.example:id">
<MvIF EXPR = "{ g.MvQUERY_Error }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'CRUD-EXAMPLES-00003', g.MvQUERY_Error ) }">
</MvIF>
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "CRUD_Example_Delete" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
<MvQUERY NAME = "Merchant"
QUERY = "{ 'DELETE FROM ' $ g.Store_Table_Prefix $ 'CRUD_Examples
WHERE id = ?' }"
FIELDS = "l.id">
<MvIF EXPR = "{ g.MvQUERY_Error }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'CRUD-EXAMPLES-00004', g.MvQUERY_Error ) }">
</MvIF>
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment