3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php define("STATE_ID", "3"); define("DATA_CACHE_TIMEOUT", "9999"); /** * Class to import data from SECC into SRDB * *@author Rochak Chauhan */ class ImportController extends Controller { public function actionBuffer() { header( 'Content-type: text/html; charset=utf-8' ); echo 'Begin ...<br />'; for( $i = 0 ; $i < 10 ; $i++ ) { echo $i . '<br />'; flush(); ob_flush(); sleep(1); } echo 'End ...<br />'; } public function actionIndex() { $t1 = date("r"); $ts1 = microtime(true); $tot = 0; header( 'Content-type: text/html; charset=utf-8' ); echo "\r\n<p> ******** Started at $t1 ******** </p>\r\n"; $connection = Yii::app() -> db; $command = $connection -> createCommand('SELECT * FROM seccsirsa LIMIT 0,10'); $rows = $command -> queryAll(); //executes the SQL statement and returns the first row of the //$res = array(); foreach ($rows as $row) { extract($row); echo " ****************************************************** "; echo "\r\n<hr /><p>Full Name: $Name_en ($Name_h) </p>\r\n"; $SRDB_District_ID = $this -> getDistrictId($District); echo "\r\n<p>District: $District ($SRDB_District_ID) </p>\r\n"; $SRDB_City_ID = $this -> getCityId($Village,$District); echo "\r\n<p>City: $Village ($SRDB_City_ID) </p>\r\n"; flush(); ob_flush(); } $t2 = date("r"); $ts2 = microtime(true); $diff = ($ts2 - $ts1); echo "\r\n<p> ******** Stopped at $t2 ******** </p>\r\n"; echo "\r\n<p> ******** Total Execution Time: $diff microseconds ******** </p>\r\n"; echo "\r\n<p> ******** Total Records Imported: $tot ******** </p>\r\n"; } /** *Function to get District ID from District Name * *@param string $District *@param int */ private function getDistrictId($District) { //Select if record exists $District = trim(strtolower($District)); $connection = Yii::app() -> db; $connection -> active = true; $command = $connection -> createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$District' AND LR_Type='District' "); $row = $command -> queryRow(); //If no record found if ($row === false) { //Insert record in DB (Master Table) $command = $connection -> createCommand("INSERT INTO tblLandRegion (LR_Name,LR_Type) VALUES('$District', 'District') "); $rowCount = $command -> execute(); if ($rowCount == 0) { die("\r\n<hr />FATAL ERROR 0x01: Failed to insert $District in Master table :: " . __FILE__ . " at line nunber " . __LINE__); } else { //Cache and Return the PK/ID of the new inserted record. $row = Yii::app() -> cache -> get('cache_' . $District . "_" . STATE_ID); if (($row === false) || row($res)) { $District = trim(strtolower($District)); $connection = Yii::app() -> db; $command = $connection -> createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$District' AND LR_Type='District' ORDER BY LR_ID DESC"); $row = $command -> queryRow(); Yii::app() -> cache -> set('cache_' . $District . "_" . STATE_ID, $row, DATA_CACHE_TIMEOUT); } $District_ID = $row['LR_ID']; //Insert record in DB (Reference Table) $command = $connection -> createCommand("INSERT INTO tblDistrict (District_ID, State_ID) VALUES('$District_ID', '" . STATE_ID . "') "); $rowCount = $command -> execute(); if ($rowCount == 0) { die("\r\n<hr />FATAL ERROR 0x02: Failed to insert $District in Reference table :: " . __FILE__ . " at line nunber " . __LINE__); } return $District_ID; } } else { //Return the PK/ID of the record. return $row['LR_ID']; } } /** *Function to get City ID from City Name * *@param string $City *@param int */ private function getCityId($City, $District) { //Check record in Cache $row = Yii::app() -> cache -> get('cache_' . $City . "_" . $District); if (($row === false) || row($res)) { //Select if record exists $City = trim(strtolower($City)); $connection = Yii::app() -> db; $connection -> active = true; $command = $connection -> createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$City' AND LR_Type='City' "); $row = $command -> queryRow(); } //If no record found if ($row === false) { //Insert record in DB (Master Table) $command = $connection -> createCommand("INSERT INTO tblLandRegion (LR_Name,LR_Type) VALUES('$City', 'City') "); $rowCount = $command -> execute(); if ($rowCount == 0) { die("\r\n<hr />FATAL ERROR 0x01: Failed to insert $City in Master table :: " . __FILE__ . " at line nunber " . __LINE__); } else { //Cache and Return the PK/ID of the new inserted record. $row = Yii::app() -> cache -> get('cache_' . $City . "_" . $District); if (($row === false) || row($res)) { $District = trim(strtolower($District)); $connection = Yii::app() -> db; $command = $connection -> createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$City' AND LR_Type='City' ORDER BY LR_ID DESC"); $row = $command -> queryRow(); Yii::app() -> cache -> set('cache_' . $City . "_" . $District, $row, DATA_CACHE_TIMEOUT); } $City_ID = $row['LR_ID']; //Insert record in DB (Reference Table) $command = $connection -> createCommand("INSERT INTO tblCity (District_ID, City_ID) VALUES('$District_ID', '$City_ID') "); $rowCount = $command -> execute(); if ($rowCount == 0) { die("\r\n<hr />FATAL ERROR 0x02: Failed to insert $District in Reference table :: " . __FILE__ . " at line nunber " . __LINE__); } return $City_ID; } } else { //Cache and Return the PK/ID of the record. Yii::app() -> cache -> set('cache_' . $City . "_" . $District, $row, DATA_CACHE_TIMEOUT); return $row['LR_ID']; } } } ?>
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Fatal error: Class 'Controller' not found in /in/XsBoe on line 10
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught Error: unknown class Controller in /in/XsBoe:10 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Fatal error: unknown class Controller in /in/XsBoe on line 10
Process exited with code 255.