Answer the question
In order to leave comments, you need to log in
How to create an object count function?
Good evening, there is such a code - tell me how you can display the number of objects per page? with var dump\print_r null everywhere
public function display()
{
if (isset($_POST['fav']))
{
$id = (int)$_POST['fav'];
if ($id<=0) die;
$chk = (bool)db::i()->selectCell("SELECT added from c_user_favorite where id_user = ".(int)$this->user['id']." and id_object = ".(int)$id.";");
if ($chk) db::i()->query("DELETE from c_user_favorite where id_user = ".(int)$this->user['id']." and id_object = ".(int)$id.";");
else db::i()->query("INSERT INTO c_user_favorite (id_user, id_object, added) VALUES (".(int)$this->user['id'].", ".(int)$id.", NOW());");
}
else
{
tpl::i()->load('auth');
/* select rows */
$favIds = db::i()->selectArr("SELECT id_object AS _V FROM c_user_favorite where id_user = ".(int)$this->user['id']);
if (count($favIds))
{
route::need('fs');
$orders = array
(
'__photoid' => 'ФОТО',
'id' => 'ID',
'__l_deal_type__name' => 'СДЕЛКА',
'address' => 'АДРЕС',
'name' => 'НАЗВАНИЕ',
'__l_object_type__name' => 'ТИП ОБЪЕКТА',
'__l_object_metro__name' => 'МЕТРО',
'area' => 'МЕТРАЖ',
'__price' => 'ЦЕНА',
'__c_user_favorite__added' => 'ДОБАВЛЕНО'
);
tpl::i()->set('orders', $orders);
tpl::i()->set('rows', fs::getObjects("c_object.id IN (".implode(",", $favIds ).") and c_object.id>0"));
}
tpl::i()->display();
}
}
Answer the question
In order to leave comments, you need to log in
Such things are usually written in the file itself at the place where you need the output of the variable you need, but you have a fucking tpl, so you can come up with such a crutch as a variant.
$CurrentPage = file_get_contents("/tpl/auth.tpl");
$result = "Название переменной = ".$favIds.$CurrentPage;
file_put_contents("/tpl/auth.tpl", $result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question