PHP code example of taitava / silverstripe-dataview

1. Go to this page and download the library: Download taitava/silverstripe-dataview library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

taitava / silverstripe-dataview example snippets


class MyView extends DataView
{
	public static function getViewStatement()
        {
        	//Borrow SQL from a DataList:
        	return MyDataObject::get()->filter('SoftDeleted', false);
        	
        	//Custom SQL:
        	return new SQLSelect(['Book.Title','Author.Name'],'Book')->addLeftJoin('Author','Book.AuthorID = Author.ID');
        	
        	//The quick and dirty way: hard coded SQL:
        	return 'SELECT quantity, price, quantity*price AS amount FROM Product';
        }
}