Page 1 of 1

Retrieving Values from SQL Select in a Trigger

Posted: 2010-04-02 03:11
by FlyOTW
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.

Re: Retrieving Values from SQL Select in a Trigger

Posted: 2010-04-02 03:15
by FlyOTW
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 :)

Re: Retrieving Values from SQL Select in a Trigger

Posted: 2010-04-07 15:47
by Fred
Hi FlyOTW,
Would you post an article about this on the main site please?
Even if it is ADDT/Interakt Docs

Thanks