Jump to content

[SOLVED] How to return an array from with in a class method?


Recommended Posts

Hi folks! I'm trying to return an array that was created in a class method to the calling script as follows:

 

class images extends DatabaseObject {

 

          public function image_inodes_retrieve() {

  $nodelist = array();

  global $database;

  $clean_id = $database->escape_value($this->masterid);

   

  $sql  = "SELECT * FROM filedata WHERE masterid = ";

  $sql .= $clean_id;

  $sql .= " ORDER BY id";

 

 

  if (!$result = $database->query($sql)) {

          die("Failure to retrieve list of file inodes");

      }

 

    while ($current = $database->fetch_object($result)) {

          $nodelist[] = $current->id;

  //return $nodelist;

        }

 

 

 

 

}

 

 

 

}

 

If I echo the array with in the method using print_r() after calling from the original script as follows:

 

$image_info_retrieved    = new images();

$nodes = $image_info_retrieved->image_inodes_retrieve();

 

The array structure is printed correctly!

But if I try to return the array to the original script for example the array is

truncated! I know I'm doing it incorrectly so if you know how to do this

please enlighten me?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.