create table if not exists scripts (script char(200)) if not used("scripts") use scripts endif select scripts append blank replace script with 'for ($i = 1; $i <= 10; $i++) {' + CHR(13) + '// process commands;'; + CHR(13) + '}' + CHR(13) execphp(script) // Text constant execphp('for ($i = 1; $i <= 10; $i++) {' + CHR(13) + '// process commands;'; + CHR(13) + '}' + CHR(13)) // Memory variable m_script = 'for ($i = 1; $i <= 10; $i++) {' + CHR(13) + '// process commands;'; + CHR(13) + '}' + CHR(13) execphp(m_script)
https://www.lianja.com/doc/index.php/EXECPHP()
PHP:
open a Lianja database:
$db = Lianja::openDatabase("southwind");
Can filter the records that are returned using the data restriction methods.
PHP
Access the customers table using SQL:
$rs = $db->openRecordSet("select * from customers");
Or alternatively with noSQL:
$rs = $db->openRecordSet("customers");
To position on the first record in a recordset use the moveFirst() method.
$rs->moveFirst();
When positioned on a particular record in a recordset can extract data using the fields() method.
for ($i=0; $i ‹ $rs->fields->count(); ++$i) { $name = $rs->fields($i)->name; $value = $rs->fields($i)->value; }
The fields() method can also take the field name as an argument as well as the column ordinal position.
$value = $rs->fields("amount")->value;
When open a recordset with an SQL select statement, the data selected is only that which matches the where condition of the select statement. If open a table with noSQL e.g.
$rs = $db->openRecordSet("customers");
When opening a table in noSQL mode, can lookup records by keys.
$rs = $db->openRecordSet("customers"); $rs->index = "id"; $rs->seek("12345"); if (!$rs->found) { // key was not found. }
Add new blank records to a recordset using the addNew() method.
$rs->addNew();
After executing addNew() the record is not written until the update() method is called. This allows you to update the fields of the blank record prior to it being committed into the table.
Update records in a recordset using the update() method.
$rs = $db->openRecordSet("customers"); $rs->index = "id"; $rs->seek("12345"); if ($rs->found) { $rs->fields("amount")->value = $rs->fields("amount")->value + 1000; $rs->update(); }
Delete records in a recordset:.
$rs = $db->openRecordSet("customers"); $rs->index = "id"; $rs->seek("12345"); if (! $rs->noMatch) { $rs->delete(); }
Close a recordset using the close() method.
$rs->close();
Thanks for introducing me to Lianja app builder.
LikeLiked by 1 person