$tableActivityActions = Engine_Api::_()->getDbTable('actions', 'activity');
$tableActivityActionsName = $tableActivityActions->info('name');
$tableActivityLikes = Engine_Api::_()->getDbTable('likes', 'activity');
$tableActivityLikesName = $tableActivityLikes->info('name');
$tableCoreLikes = Engine_Api::_()->getDbTable('likes', 'core');
$tableCoreLikesName = $tableCoreLikes->info('name');
// get sub-select from first table
$selectCoreLikes = $tableCoreLikes->select()
->from($tableCoreLikesName, array('COUNT(*)'))
->where("$tableCoreLikesName.user_id = ?", $user_id)
;
// get sub-select from second table
$selectActivityLikes = $tableActivityActions->select()
->from($tableActivityActionsName, array('COUNT(*)'))
->join($tableActivityLikesName, "$tableActivityLikesName.resource_id = $tableActivityActionsName.action_id", null)
->where("$tableActivityLikesName.poster_id != $tableActivityActionsName.object_id")
->where("$tableActivityActionsName.object_id = ?", $user_id)
;
$db = $tableCoreLikes->getAdapter();
$selectTotalLikes = $db->query('SELECT (' . $selectCoreLikes->__toString() . ') + ('
. $selectActivityLikes->__toString() . ')');
$result = $selectTotalLikes->fetchAll();
$totalLikes = array_shift($result[0]);
// Получаем первый день текущей недели
$getFirstDay = date('Y-m-d 00:00:00', strtotime('this week', time()));
<div class = 'sidebar'>
<ul class = 'info-line'>
[[!Wayfinder?
&startId= `2`
&hideSubMenus= `1`
&ignoreHidden= `1`
]]
</ul>
</div><!--sidebar-->