Menu

#6 getbyfunction warning

open
nobody
None
5
2005-02-21
2005-02-21
Anonymous
No

call $db->getbyfunction("my_filter", "name");

if the result set is empty, a warning is generated

Notice: Undefined variable: sresult in ffdb.inc.php on
line 2464

I modifed
function order_by(&$result, $orderby)
{
$record_count = count($result);

if ($record_count == 0)
return $result;
....

to have the check for record_count == 0

Discussion

  • Aron

    Aron - 2005-04-28

    Logged In: YES
    user_id=1196724

    Don't you mean "if($record_count != 0)"? That way it will
    only return if it has records.

     
  • Nobody/Anonymous

    Logged In: NO

    A better fix perhaps would be to initialize $result to an empty array inside of getbyfunction() before the for loop:

    // Read each record and add it to an array
    $rcount = 0;
    $result = array(); // THIS LINE ADDED
    foreach($index as $offset)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.