Hi I’m new to Yii and I had a problem with my code.
This is my views file Display.php
<script>
var auto_refresh = setInterval(
function()
{
$('#myDIV').fadeOut('slow').load('MyController.php').fadeIn("slow");
}, 5000);
</script>
<div id="myDIV" >
<div>Latest Count: <?php echo $db[0]['TotalCount'];?></div>
<div>Latest EmpID: <?php echo $db[0]['EmpID'];?></div>
</div>
This is where my models file DailyResultAction.php
<?php if ( ! defined('YII_PATH')) exit('No direct script access allowed');
define("MainDB","MyDB");
class DailyResultAction{
public function GETResultQuery(){
$mysql = new TestMYSQL();
$sqlstr = "Select *,(select count(*) from myTable) as TotalCount from ".MainDB.".myTable where EmpID=(select max(EmpID) from ".MainDB.".myTable)";
$result = $mysql->MyQueryAll(MainDB,$sqlstr);
unset($mysql);
return $result;
}
This is my controller file MyController.php
<?php
class MyController extends Controller
{
public function ControllerResult()
{
$this->layout='myLayout';
$Display= new DailyResultAction();
$model = $Display->GETResultQuery();
$this -> render('Display',array('db'=>$model));
}
}
?>
The auto refresh doesn’t work… I wonder is my mistaken in assign
$(’#myDIV’).fadeOut(‘slow’).load(‘MyController.php’).fadeIn(“slow”);
please help