Retrieving Values from SQL Select in a Trigger

Any tips and tricks that has to with the ADDT that doesn't fit into one of the other categories
FlyOTW
Posts: 11
Joined: 2010-03-26 23:09

Retrieving Values from SQL Select in a Trigger

Post by FlyOTW » 2010-04-02 03:11

Get the values from a SQL statement within an ADDT trigger that do not exist within the original transaction.

$querySEL = "SELECT dbfield1, dbfield2 FROM table";
$result = $tNG->connection->execute($querySEL);
$numberOfRecords = $result->recordCount();
......
while (!$result->EOF)
{
$result->Fields('dbfield1');
$result->Fields('dbfield2');
$result->MoveNext();
}
}

-----
So the important functions are $result->EOF which indicates you perused all records. To retrieve a column from the current row use $result->Fields('>>>fieldname<<<')

To get to the next row, use $result->MoveNext(). There is also a MoveFirst function, just in case you need to read all rows again.

FlyOTW
Posts: 11
Joined: 2010-03-26 23:09

Re: Retrieving Values from SQL Select in a Trigger

Post by FlyOTW » 2010-04-02 03:15

Also you can get db value for use in a custom trigger like so.

$Value = $tNG->getColumnValue("Field from database");

It must be a part of the original transaction though.
This is also already in ADDT/Interakt Docs :)

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

Re: Retrieving Values from SQL Select in a Trigger

Post by Fred » 2010-04-07 15:47

Hi FlyOTW,
Would you post an article about this on the main site please?
Even if it is ADDT/Interakt Docs

Thanks

Post Reply