5 Replies Latest reply on Aug 1, 2010 12:40 PM by Albert S.

    Change extension in delete trigger.

    Albert S. Level 3

      Hi,

      I am trying to change the extension in the delete trigger. This is one of the many attempts. I could use some help on it.

      I've tried a few different ways of getting the value from the db but none seem to work.

      I know that if I just manually write the name in the rename rule it will delete so basically I'm not able to get the value from the transaction dynamically for some reason. So below are some attempts. Any help is appreciated.


      TiA
      Bert

       

      //start Trigger_FileDelete trigger
      function Trigger_FileDelete5(&$tNG) {
          $queryFileName = sprintf("SELECT filename_vid from video_vid WHERE video_vid = %s", $_GET['video_vid']);
          $result = $tNG->connection->execute($queryFileName);
          while (!$result->EOF) { $getFileName = $result->Fields('filename_vid'); }
       
        $deleteObj = new tNG_FileDelete($tNG);
        $deleteObj->setFolder("../../tour/");
        $filename = explode(".",$getFileName);
        $filename = $filename[0].".mp4";
        $deleteObj->setRenameRule("".$filename."");
        return $deleteObj->Execute();
      }
      //end Trigger_FileDelete trigger

       

      OR

       

      //start Trigger_FileDelete trigger
      function Trigger_FileDelete5(&$tNG) {
        $deleteObj = new tNG_FileDelete($tNG);
        $deleteObj->setFolder("../../tour/");
        $deleteObj->setRenameRule("{KT_name}.mp4");
        return $deleteObj->Execute();
      }
      //end Trigger_FileDelete trigger

        • 1. Re: Change extension in delete trigger.
          Günter Schenk Level 4

          Hi Albert,

           

          {KT_name} represents the name of the stored file without the extension, whereas {KT_ext} represents - guess what - the extension. A complete file name will have to comprise both placeholders including the dot (.), so please try with:

           

          $deleteObj->setRenameRule("{KT_name}.{KT_ext}");

           

          Cheers,

          Günter

          • 2. Re: Change extension in delete trigger.
            Albert S. Level 3

            Hi Gunter,

             

            To give you an example of what I'm trying to do. In the database the filename is "thefilename.flv"

            I have a delete trigger that will delete this file with out any problems but at the same time "thefilename.flv" is being created so is "thefilename.mp4"


            But when I call or use that file ".mp4" in the site I just strip the name from "thefilename.flv" and add the .mp4 in any of my code, but its still only 1 database entry in the db "thefilename.flv"

             

            While the "thefilename.flv" deletes with no problem I am adding a 2nd delete transaction to also delete the ".mp4".

            So in the 2nd delete transaction I am making it strip the name and add the ".mp4"

             

            But when I do this

            $deleteObj->setRenameRule("{KT_name}.mp4"); which I thought would be a no brainer and work is not working.

             

            But if I add this

            $deleteObj->setRenameRule("thefilename.mp4"); it works fine so that  leads me to think for some reason {KT_name} is not working.

             

            So thats why I went more elaborate and added the sql query prior in the one example because its not getting the name for some reason but thats not working either.

             

            Do you know of any tricks to echo out the results in a delete trigger so I figure out what data is ending up inside of

            $deleteObj->setRenameRule("{KT_name}.mp4");

             

            Thanks again for responding

            bert

            • 3. Re: Change extension in delete trigger.
              Günter Schenk Level 4

              So you have 2 - sort of - cascaded delete file transactions in that page, and the second one appears to lose the {KT_name} value ? Maybe it´s just the usual "PHP variable scope" issue, after all you´re dealing with two functions.

               

              Just an idea: how about assigning the filename (respectively the part without the file extension) you´re retrieving from a recordset to a custom Session Variable (which is Global by default and hence can be used in multiple functions without further ado) and within your delete trigger - functions use this Session Variable instead of the placeholder {KT_name} ?

               

              Cheers,

              Günter

              • 4. Re: Change extension in delete trigger.
                Albert S. Level 3

                Hi,

                 

                Yea that worked just changing it to a session.

                 

                I still think its strange that {KT_name} is not working.

                In the same delete triggers I use ADDT markup in setFolder ("{database_field}")  to locate the folder and that works fine.

                 

                Thank you for responding

                 

                • 5. Re: Change extension in delete trigger.
                  Albert S. Level 3

                  Also just to further add. I am making the transaction with the extension change {KT_name} trigger first so if the PHP scope issue occurs its on the delete trigger that is standard.