Created
January 17, 2012 09:43
-
-
Save tyoro/1625900 to your computer and use it in GitHub Desktop.
tiarraMetroの初回ロードのクロスクエリを廃止して、メモリサイズオーバー対策の為に個別にループ化したもの
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
function getUnreadList( $server = "", $sort = 0 ){ | |
$sql = "SELECT | |
channel.id, | |
channel.name, | |
substring(channel.name, locate('@', channel.name) + 1) as network | |
FROM channel | |
WHERE view = ?"; | |
$values = array(1); | |
if( !empty($server) ){ | |
$sql .= " WHERE name like ? "; | |
$values[] = "%@".$server; | |
} | |
$order = $this->detectOrder($sort); | |
if (!empty($order)) { | |
$sql .= $order; | |
} | |
$list = $this->_conn->getArray($this->_conn->Prepare($sql), $values); | |
foreach( $list as $key => $c ){ | |
$sql = "SELECT | |
count(*) as cnt | |
FROM channel | |
LEFT JOIN log ON channel.id = log.channel_id | |
WHERE channel.readed_on < log.created_on | |
&& channel.id = ".$c['id']; | |
$list[ $key ][ 'cnt' ] = $this->_conn->GetOne( $sql ); | |
} | |
return $list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment