Announcement

Collapse
No announcement yet.

How can I add a row to my "shipping" table using mvt:do?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How can I add a row to my "shipping" table using mvt:do?

    Hello forum:
    I have this example that adds a row to the s01_BasketCharges table:

    <mvt:assign name="l.basket_charge:basket_id" value="g.Basket:basket_id" />
    <mvt:assign name="l.basket_charge:type" value="'TAX'" />
    <mvt:assign name="l.basket_charge:descrip" value="'Custom Description'" />
    <mvt:assign name="l.basket_charge:amount" value="g.final_tax_calulation" />
    <mvt:assign name="l.basket_charge:disp_amt" value="g.final_tax_calulation" />
    <mvt:assign name="l.basket_charge:tax_exempt" value="0" />
    <mvt:do file="g.Module_Library_DB" name="l.ok" value="BasketCharge_Insert( l.basket_charge )" />

    I would like to modify this code to insert a row into my "shipping" table.
    It appears that I would set a value for each column in my table using the <mvt:assign statement where name = the column name.
    but how should the mvt:do be coded? Will my table have to be added to the g.Module_Library_DB? I would guess so.
    And I'm guessing that the insert function there should be named "shipping_Insert".

    And how do you check the l.ok variable which I'm guessing has the result of the DB function. A 0 or 1 or ?.

    What do I have to do to get a "shipping_Insert" function into the Module_Library_DB?
    Can someone do that for me? I imagine it has to be compiled.

    Thanks, Larry
    Larry
    Luce Kanun Web Design
    www.facebook.com/wajake41
    www.plus.google.com/116415026668025242914/posts?hl=en



    #2
    Since the "shipping" table is your own creation, there aren't any functions built into the store for reading or writing it. You'll have to roll your own. I think one of the "Tool' modules has a command that can execute SQL queries. You'll need to use that instead of mvt:do. The rest of the code can be similar to your BasketCharge snippet.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Hi Kent:
      Took a look at both toolkit and toolbelt and didn't see anything there to do this. Did I overlook it?
      Looked thru the modules in the Miva store for other products that might have the capability but non of them appeared to have this ability.

      It would be nice to have a less focused DB function that would allow the naming of the table to be modified instead of have a bunch of functions that are each assigned to a specific table.
      As they say: "how hard can that be".;).
      Larry
      Luce Kanun Web Design
      www.facebook.com/wajake41
      www.plus.google.com/116415026668025242914/posts?hl=en


      Comment


        #4
        Originally posted by wajake41 View Post
        Hi Kent:
        Took a look at both toolkit and toolbelt and didn't see anything there to do this. Did I overlook it?
        Looked thru the modules in the Miva store for other products that might have the capability but non of them appeared to have this ability.

        It would be nice to have a less focused DB function that would allow the naming of the table to be modified instead of have a bunch of functions that are each assigned to a specific table.
        As they say: "how hard can that be".;).
        Its not a question of how hard it would be, but rather, the danger of opening up database tables that widely when its pretty clear, most store owners don't have any idea of how databases work.

        But back to your issue. Its not clear what you are trying to accomplish, which is imperative to getting the RIGHT answer. However, if you are trying to insert a "shipping" charge into the basket charges table (where they do go) you can simply modify that BasketChargeInsert code accordingly.

        <mvt:assign name="l.basket_charge:basket_id" value="g.Basket:basket_id" />
        <mvt:assign name="l.basket_charge:type" value="'SHIPPING'" />
        <mvt:assign name="l.basket_charge:descrip" value="('What You Want to Show On the Basket Screen as a Description')" />
        <mvt:assign name="l.basket_charge:amount" value="(variable for amount)" />
        <mvt:assign name="l.basket_charge:disp_amt" value="(variable for amount)" />
        <mvt:assign name="l.basket_charge:tax_exempt" value="0" /> (0 or 1 depending on whether tax is charged against this amount)
        <mvt:do file="g.Module_Library_DB" name="l.ok" value="BasketCharge_Insert( l.basket_charge )" />
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          Hi Bruce:
          We need to be able to insert to our own tables, one being 'shipping', located within the Miva database. If mvt:do can be used to update Miva's tables, I don't understand how updating our own tables would be an additional security risk. The risk already exists via the Miva DB functions doesn't it?. I've previously been given both delete and insert examples here on the forum.
          Larry
          Luce Kanun Web Design
          www.facebook.com/wajake41
          www.plus.google.com/116415026668025242914/posts?hl=en


          Comment


            #6
            <mvt:do file="g.Module_Library_DB" name="l.ok" value="BasketCharge_Insert( l.basket_charge )" /> is performing an API function. (API functions provide protection from corruption by ensuring that all related tables get updated. What you are looking for is raw SQL access (which, as was mentioned is available via Tool Belt), which I'd really be surprised if Miva provided that level of access for...though they might. As a site developer, I'd personally never add that to a template for the reasons I've mentioned before. I'd use a custom module and call that from the template if necessary.

            Bruce Golub
            Phosphor Media - "Your Success is our Business"

            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
            phosphormedia.com

            Comment

            Working...
            X