Jump to content

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


willaguila

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.