create_report

 
          create_report()  
This method is responsible for actually creating the report. Before doing this, it validates the report options and throws exceptions if there is a problem.
# This method is available in both the community edition and the commercial edition .

# Returns

This method returns the generated report URL if the report is created successfully, and return false otherwise

# Exceptions

Error NO Error Message Description
1Could not create the report directory. Permission This exception occurs due to permission error. You need to make sure you give 755 permissions to the "/sre_reports" in the case of native applications or "/public/sre_reports" in the case of laravel applications.
2Could not write in the 'init.php' configuration fiThis exception occurs due to permission error. You need to make sure you give 755 permissions to the "/sre_reports" in the case of native applications or "/public/sre_reports" in the case of laravel applications.
16No tables were selected for the report!You need to call the "select_tables" method using the "ReportOptions" instance you created.
15No columns were selected for the reportYou need to call the "select_fields" or the"select_all_fields" method using the "ReportOptions" instance you created.
17The datasource is set to SQL yet a SQL query is noYou need to call the "set_sql" method using the instance of the "ReportOptions" which you created.
18 The data source is not recognized!You need to pass either SRE_Table or SRE_SQL (Constants::SRE_Table or Constants::SRE_SQL in case of laravel applications) as the second parameter to the constructor of the "ReportOptions" class.
19Connection parameters are missing!You need to set default connection parameters in the configuration file of SmartReportEngine, which you can find at "sre_config/config.php" in the case of native PHP applications or "sre/SmartReportingEngine/src/Configs.php" in the case of laravel applications.
44The 'security_init()' should be called before any When creating private reports, you should call "security_init" method using the "ReportOptions" instance which you are using to initialize the security settings of your report such as used session name, login, and logout pages.
50The access mode of the report is private, yet no sWhen creating a private report, you should call one or more of the "security_check_session_" methods to define all the session validations needed for your private report.
51The access mode of report is public, yet some sessNo session validations can be done for public reports which meant to be accessed by everyone without any session validations.
55The access mode of report is public, yet the 'secNo session validations can be done for public reports which meant to be accessed by everyone without any session validations. So you need to call the "security_init" method for private reports only!
52The access mode of report is private yet the loginYou need to set a default login page in the configuration file of SmartReportEngine, which you can find at "sre_config/config.php" in the case of native PHP applications or "sre/SmartReportingEngine/src/Configs.php" in the case of laravel applications.
53The access mode of report is private yet the logouYou need to set a default logout page in the configuration file of SmartReportEngine, which you can find at "sre_config/config.php" in the case of native PHP applications or "sre/SmartReportingEngine/src/Configs.php" in the case of laravel applications.

# Code Example

 
           try{
$report = new ReportOptions(SRE_PUBLIC_REPORT);
$report->select_tables(array("items"))
       ->set_grouping(array("country"))
       ->select_all_fields();
$engine = new CustomEngine($report);
$report_path = $engine->create_report();
echo "Your report URL:" . $report_path;
} catch (Exception $ex) {
   echo 'Caught exception message:  '.  $ex->getMessage(). "\n";
   echo 'Caught exception code: '.$ex->getCode(). "\n";
   echo 'Caught exception Trace:'. $ex->getTraceAsString() . "\n";
}