Поведение функции mysqli_num_rows() зависит от того, используется ли буферизованная или небуферизованная результирующая выборка. Для небуферизованной выборки mysqli_num_rows() не вернет правильное число рядов пока все ряды не будут получены и обработаны.
SELECT COUNT(*)
FROM (SELECT `right_id`
FROM `prs_rights_forum`
WHERE `category_id` = :category)
AS `forum`
LEFT JOIN (SELECT `right_id`
FROM `prs_rights_users`
WHERE `user_id` = :user)
AS `user` USING(`right_id`)
WHERE `user`.`right_id` IS NULL
function total_price($cart) {
$total_price = 0.0;
db_connect(); /* Надо переписать на mysqli */
if(is_array($cart)){
$query = $mysqli->prepare("SELECT `price` FROM `sdvd_products` WHERE `id` = ?");
$query->bind_param('i', $id);
$query->bind_result($item_price);
foreach($cart as $id => $qty) {
$query->execute();
if ($query->fetch())
$total_price += $item_price * $qty;
}
$query->close();
}
return $total_price;
}
SELECT DISTINCT `rt`.`id`, `rt`.`title`, `rt`.`sex`
FROM `relation_types` AS `rt`
LEFT JOIN (SELECT `type_id` FROM `relations` WHERE `user_id_from` = :user_id) AS `r`
ON `r`.`type_id` = `rt`.`id`
WHERE (`rt`.`is_multiply` = TRUE OR `r`.`type_id` IS NULL)
AND (`rt`.`sex` = 0 OR `rt`.`sex` = :second_user_sex
OR (`rt`.`sex` = 3 AND :user_sex != :second_user_sex))
SELECT `today`.`user_id`, `today`.`value`, `yesterday`.`value`, `users`.`name`
FROM `values` AS `today`
INNER JOIN `values` AS `yesterday` ON `yesterday`.`user_id` = `today`.`user_id`
LEFT JOIN `users` ON `users`.`id` = `values`.`user_id`
WHERE `today`.`date` = CURDATE()
AND `yesterday`.`date` = CURDATE()-INTERVAL 1 DAY
AND `yesterday`.`value` > `today`.`value`
UPDATE `table` SET
`email` = IF(LOCATE('Мыло|', `info`) = 0, NULL,
SUBSTRING_INDEX(SUBSTRING_INDEX(`info`, 'Мыло|', -1), '|', 1)),
`phone` = IF(LOCATE('Телефон|', `info`) = 0, NULL,
SUBSTRING_INDEX(SUBSTRING_INDEX(`info`, 'Телефон|', -1), '|', 1)),
`skype` = IF(LOCATE('Skype|', `info`) = 0, NULL,
SUBSTRING_INDEX(SUBSTRING_INDEX(`info`, 'Skype|', -1), '|', 1));