I am using the format as below (see site: http://php.net/manual/en/pdostatement.fetchall.php)
Code: Select all
<?php
$sth = $dbh->prepare("SELECT * FROM employees");
$sth->execute();
$result = $sth->fetchAll();
print_r($result);
?>
I would like to load it into my datagrid, but I believe the format is not appropriate. What is the appropriate format for datagrid? I don't mind changing my PDO prepared statement either if it makes it easier for Livecode in the end / or increases performance. Most likely I will have to use a repeat loop of some kind to help me convert it to a variable.Array
(
[0] => Array
(
[idAI] => 1
[0] => 1
[EmpId] => 987
[1] => 987
[Name] => James Smith
[2] => James Smith
)
[1] => Array
(
[idAI] => 2
[0] => 2
[EmpId] => 123
[1] => 123
[Name] => Jane Robert
[2] => Jane Robert
)
[2] => Array
(
[idAI] => 3
[0] => 3
[EmpId] => 456
[1] => 456
[Name] => Tom Jones
[2] => Tom Jones
)
)
Any help would be appreciated, thanks.
This is what I used previously, but I would like to use PHP for security reasons.
Code: Select all
global gConnectionID
on mouseUp
connectToDB
## Connect to the database
## Query the database for contact details to be displayed in the field
put "SELECT * from employees" into tSQL
put revDataFromQuery(tab,return,gConnectionID,tSQL) into tRecords
set the dgText of group "DataGrid 1" to tRecords
closeDB gConnectionID
end mouseUp