Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 28. november 2021
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Trigger use

phpMyEdit General     Trigger use
Odoslať novú tému   Odpovedať na tému   Choď na stránku 1, 2, 3, 4, 5  Ďalší  
 
tonymcc     Založený: 15.01.2009   Príspevky: 6  
Príspevok Zaslal: 2009-01-15 07:31
Návrat hore  Odpovedať s citátom     

I am using version 5.7.1 right now. (I just purchased MFG but haven't gotten it yet). However, I having difficulty getting a trigger to execute at all.

The examples don't actually have much detail on how to use the triggers or enable them.

The code looks like this right now:

Kód:

<snip>
$opts['triggers']['update']['after'] = 'updatelastid.TAA.inc';

// Now important call to phpMyEdit
require_once 'phpMyEdit.class.php';
new phpMyEdit($opts);
<snip>


It does not ever run. What am I doing wrong? Everything else I've done so far is working great.


For test purposes the trigger code itself looks like this:
Kód:
<?php
    print '<br/> TRIGGER CODE EXECUTED <br/>';
    return(true);
?>


By the way.. I realize that triggers are for invisible actions, but I was not having any luck, so, just as a test I put the print call in.

What I really want to do is update a separate table with the value of the an assigned ID # + 1, I use the table lookup to get the next number and on save in Add Mode only I will increment that number. For technical reasons it has to be a sequence table not an integrated AUTO_INCREMENT field.

 
tonymcc     Založený: 15.01.2009   Príspevky: 6  
Príspevok Zaslal: 2009-01-15 10:17
Návrat hore  Odpovedať s citátom     

I have managed to get the call to work as a 'php' field option, which proves to me that at least the script will run and update the table I want. However treating it like a trigger does not.

Using a direct 'php' action measn I would have to write all the pre/post/cancel logic. I'd much prefer the trigger to work.

You can see below that I am using a values table lookup in 'ADD' mode to get the next ID number, so I just need to increment it on successful save for specific type of 'parrent' record.

Kód:
$opts['fdd']['PrimaryID'] = array(
  'name'     => 'Primary Member ID',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true,
  'values|A' => array(
     'table'       => 'coopids',
     'column'      => 'NextID',
     'filters'     => 'IDName = "PRIMARY" '),  //lookup the last ID in ADD mode
  'php'      =>'updatelastid.php'
);


Any help you may have would be appreciated.

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-01-15 21:41
Návrat hore  Odpovedať s citátom     

If you want the trigger to grab the ID of the last record added (in Add mode) then you need ['insert']['after'] instead of ['update']['after']

Posting the complete trigger would be helpful in understanding the goal.

 
tonymcc     Založený: 15.01.2009   Príspevky: 6  
Príspevok Zaslal: 2009-01-15 21:59
Návrat hore  Odpovedať s citátom     

At this point the trigger won;t execute not matter what I put in it, But here's the code I used fpr the 'php' field option call
Kód:
<?php
// TRIGGER TO UPDATE LAST ID

    $this->myquery("UPDATE `coopids` SET `LastID` = `LastID` +1 WHERE `IDName` = 'PRIMARY'");
    return(false);
?>


As you can see I don't need to know the internal record ID of the current record, I just need to increment a field in a separate table AFTER as succesful save in the main table.
I do need to be able, eventually, to check that the value of a field called 'Relationship' is equal to 'P' as a pre-req to incrementing the LastID field.

This spinnet is incomplete as I am trying to just prove that it will execute as a trigger at all right now and it does not.
--Tony

doug Napísal:
If you want the trigger to grab the ID of the last record added (in Add mode) then you need ['insert']['after'] instead of ['update']['after']

Posting the complete trigger would be helpful in understanding the goal.


 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-01-15 22:20
Návrat hore  Odpovedať s citátom     

Build in some error checking?

Kód:
if($this->myquery("UPDATE `coopids` SET `LastID` = `LastID` +1 WHERE `IDName` = 'PRIMARY'")){

   return true;

}else{

   echo "\n".'<p>'.mysql_error().'</p>';

   echo "\n".'<a href="javascript:history.go(-1)" onmouseover="self.status=document.referrer;return true">Go Back</a>';

   @mysql_close($this->dbh);

   require_once('./inc/footer.php');

   exit;

}


 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-01-15 22:21
Návrat hore  Odpovedať s citátom     

Variables available within a trigger include:
$this - object reference
$this->dbh - nitialized MySQL database handle
$this->key - primary key name
$this->key_type - primary key type
$this->key_delim - primary key deliminator
$this->rec - primary key value (update and delete only)
$newvals - associative array of new values (update and insert only)
$oldvals - associative array of old values (update and delete only)
$changed - array of keys with changed values

 
tonymcc     Založený: 15.01.2009   Príspevky: 6  
Príspevok Zaslal: 2009-01-15 22:24
Návrat hore  Odpovedať s citátom     

Well, I'll be. Changing it to [insert][after] and this minor tweak below (thanks to the mfg txt examples) seems to have done the job!

Kód:
<?php
// TRIGGER TO UPDATE LAST ID

    if($newvals['Relationship'] == 'P') {
        $this->myquery("UPDATE `coopids` SET `LastID` = `LastID` +1 WHERE `IDName` = 'PRIMARY'");
        return(false);
    }
   
?>


NOW I'll add the error checking ... I try and keep it simple to start with, thanks for the help.

 
gaxexyx     Založený: 18.04.2020   Príspevky: 1  
Príspevok Zaslal: 2020-04-18 07:21
Návrat hore  Odpovedať s citátom     

If you are a programmer and you will able to write code by yourself then you must use the latest and update version of the tool. Check the latest trigger used formula at 123helpme writers in which you can approach the different things.

 
Maximaim     Založený: 18.04.2020   Príspevky: 1  
Príspevok Zaslal: 2020-04-18 08:08
Návrat hore  Odpovedať s citátom     

If you are using the new updated version of the opensource tool then you must enjoy the new features that are included on them. They are also provide you the best paper writing service in which you can make your own software house and blog.

 
followersuk     Založený: 06.05.2020   Príspevky: 13  
Príspevok Zaslal: 2020-05-06 10:30
Návrat hore  Odpovedať s citátom     

Open-source software development is the process by which open-source software, or similar software whose source code is publicly available, is developed by ... by Epicfollowers uk

 
followersaustralia     Založený: 10.05.2020   Príspevky: 25  
Príspevok Zaslal: 2020-05-10 06:44
Návrat hore  Odpovedať s citátom     

phpMyEdit 5.7.1instant MySQL table editor and code generatorOndrej JombikDoug ... General optionsis translated using language files into user specified language. Possible ... Triggers are files that areincluded via an include() statement and ... followers italy

 
followersaustralia     Založený: 10.05.2020   Príspevky: 25  
Príspevok Zaslal: 2020-05-10 06:45
Návrat hore  Odpovedať s citátom     

I've been using PHPMyedit for a while and recently noticed a feature that I'd like to try to use. ... To include a php file I use triggers like this: ... So the general gist is that prepared statements are all that's really needed to prevent SQL injection ... buy instagram followers cheap

 
followersuk     Založený: 06.05.2020   Príspevky: 13  
Príspevok Zaslal: 2020-05-10 12:36
Návrat hore  Odpovedať s citátom     

Open-source software development is the process by which open-source software, or similar software whose source code is publicly available, is developed by ...
by https://followersuk.uk/

 
followersuk     Založený: 06.05.2020   Príspevky: 13  
Príspevok Zaslal: 2020-05-10 12:38
Návrat hore  Odpovedať s citátom     

Smart contracts, decentralized apps, smaller frameworks, new approaches to numerical computing and low-level code&#8212;the software ...by http://followersuk.co.uk/

 
followersaustralia     Založený: 10.05.2020   Príspevky: 25  
Príspevok Zaslal: 2020-05-20 12:48
Návrat hore  Odpovedať s citátom     

General options, Next. Triggers. Triggers are files that are included via include() statement that perform actions before or after insert, ... The programmer must understand and accept these risks prior to using the phpMyEdit triggers mechanism.
by http://buyactivefollowersuk.co.uk/

 
Odoslať novú tému   Odpovedať na tému   Choď na stránku 1, 2, 3, 4, 5  Ďalší  

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov