Created
January 14, 2013 21:16
-
-
Save Alex-Bond/4533581 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function actionLogger() | |
{ | |
$base = Yii::app()->db->createCommand()->select('*')->from('cr_log')->order("when DESC"); | |
$where = array(); | |
$where_replace = array(); | |
if (isset($_GET['username']) AND strlen($_GET['username']) > 0) { | |
$where[] = 'username LIKE \'%' . $_GET['username'] . '%\''; | |
} | |
if (isset($_GET['type']) AND $_GET['type'] != 0) { | |
$where[] = 'type=:type'; | |
$where_replace[":type"] = $_GET['type']; | |
} | |
if (isset($_GET['when']) AND strlen($_GET['when']) == 10) { | |
$where[] = 'DATE(`when`)=:when'; | |
$where_replace[":when"] = date('Y-m-d', CDateTimeParser::parse($_GET['when'], 'dd-MM-yyyy')); | |
} | |
$coord_pm = 10; | |
if (isset($_GET['coord_pm']) AND !empty($_GET['coord_pm'])) { | |
$coord_pm = $_GET['coord_pm']; | |
} | |
if (isset($_GET['coord_x']) AND !empty($_GET['coord_x'])) { | |
$where[] = '(x>:x_min AND x<:x_max)'; | |
$where_replace[":x_min"] = $_GET['coord_x']-$coord_pm; | |
$where_replace[":x_max"] = $_GET['coord_x']+$coord_pm; | |
} | |
if (isset($_GET['coord_y']) AND !empty($_GET['coord_y'])) { | |
$where[] = '(y>:y_min AND y<:y_max)'; | |
$where_replace[":y_min"] = $_GET['coord_y']-$coord_pm; | |
$where_replace[":y_max"] = $_GET['coord_y']+$coord_pm; | |
} | |
if (isset($_GET['coord_z']) AND !empty($_GET['coord_z'])) { | |
$where[] = '(z>:z_min AND z<:z_max)'; | |
$where_replace[":z_min"] = $_GET['coord_z']-$coord_pm; | |
$where_replace[":z_max"] = $_GET['coord_z']+$coord_pm; | |
} | |
$where_sql = null; | |
if (count($where) > 0) { | |
$where_sql = implode(" AND ", $where); | |
} | |
if ($where_sql != null) | |
$base->where($where_sql, $where_replace); | |
$count = clone $base; | |
$count = $count->select("count(*) as count")->queryRow(); | |
$count = $count['count']; | |
$pages = new CPagination($count); | |
$pages->pageSize = 100; | |
$pages->applyLimit($base); | |
$base = $base->queryAll(); | |
$this->render('logger', array('base_model' => $base, 'pages' => $pages)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment