More usage of dbm::is_result($r) instead of count($r):
- count() returns very different results and never a boolean (not even false on error condition). - therefore you should NOT use it in boolean expressions. This still *can* be done in PHP because of its lazyness. But it is discouraged if it comes to more clean code. Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
parent
293436e5fd
commit
6a8a36f12d
115 changed files with 439 additions and 437 deletions
|
@ -126,7 +126,7 @@ function network_init(&$a) {
|
|||
intval(local_user()),
|
||||
dbesc($search)
|
||||
);
|
||||
if(! count($r)) {
|
||||
if(! dbm::is_result($r)) {
|
||||
q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
|
@ -182,7 +182,7 @@ function saved_searches($search) {
|
|||
|
||||
$saved = array();
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
$saved[] = array(
|
||||
'id' => $rr['id'],
|
||||
|
@ -381,7 +381,7 @@ function network_content(&$a, $update = 0) {
|
|||
);
|
||||
|
||||
$str = '';
|
||||
if(count($r))
|
||||
if(dbm::is_result($r))
|
||||
foreach($r as $rr)
|
||||
$str .= '<' . $rr['id'] . '>';
|
||||
if(strlen($str))
|
||||
|
@ -463,7 +463,7 @@ function network_content(&$a, $update = 0) {
|
|||
intval($group),
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
if(! count($r)) {
|
||||
if(! dbm::is_result($r)) {
|
||||
if($update)
|
||||
killme();
|
||||
notice( t('No such group') . EOL );
|
||||
|
@ -507,7 +507,7 @@ function network_content(&$a, $update = 0) {
|
|||
AND (NOT `blocked` OR `pending`) LIMIT 1",
|
||||
intval($cid)
|
||||
);
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
|
||||
|
||||
$entries[0] = array(
|
||||
|
@ -609,7 +609,7 @@ function network_content(&$a, $update = 0) {
|
|||
intval($_SESSION['uid'])
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
if(dbm::is_result($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue