Please enable JavaScript to view this site.

Navigation: Using PHPRunner > REST API Connections and Views

Code Views

Scroll Prev Next More

 

You can also create views are based on PHP code. For instance, you can display a list of files from the file system. Handy, if you need to implement a file manager for instance. PHPRunner will build the sample code for you and you can extend it any way you need it.

 

To create a Code View create a SQL View first and then click "Switch to PHP mode" button. You can switch back to SQL mode if you need to.

 

Here is an example of just supplying some data as an array:

 

 

$data = array();  
$data[] = array("id"=>1, "name"=>"aaa");  
$data[] = array("id"=>2, "name"=>"bbb");  
$data[] = array("id"=>3, "name"=>"ccc");  
$result = new ArrayResult( $data );  
 
if( !$result ) {  
   $dataSource->setError( DB::LastError() );  
  return false;  
}  
// filter results, apply search, security & other filters  
$result = $dataSource->filterResult( $result, $command->filter );  
// reorder results as requested  
$dataSource->reorderResult( $command, $result );  
return $result;  

 

 

You will also need to define two fields, id (integer) and name (varchar). This is it, you can build your app and all functions like search, filters, pagination will work out of the box. If you ever needed to build pages that are not tied to any database table - your prayers were answered. You can use Code Views, for instance, to build a feedback form where data entered by the user is sent to your email.

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software