Re: Help With Passing Data To/From Class

From: Date: Sat, 06 Jan 2001 01:21:18 +0000
Subject: Re: Help With Passing Data To/From Class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32993@lists.php.net to get a copy of this message
In article <B668F4CA.29B0E%ckwei@sciencentral.com>, "Clarence Kwei" <ckwei@sciencentral.com> wrote: can you post your people Class def and your db Class def? Jeff > I'm new to OOP and hope I'm doing this right. I've got a class that > handles info/functions about "people" - ex. their name. > > In my HTML page I have the following: > > ------------------ > $select_people = new people; > > $search_results = array(); > > $search_results = $select_people->select_person_by_lname ($view, $sort, > $order); > ------------------ > > In the class, I have the following function: > > ------------------ > function select_person_by_lname ($view, $sort, $order) { > > $query = "SELECT id FROM people WHERE last_name like '$view%' > ORDER > BY $sort $order"; > > $db = new db_sql; > > $db->query($query); > > $select_person_by_lname_array = array (); > > $num_results = $db->number_rows (); > if ($num_results > 0) { $this->valid = "Y"; } else { > $this->valid > = > "N"; } > > $i = 0; > while ($db->next_record ()) { > $select_person_by_lname_array[$i] = $db->Record["id"]; > $i ++; > } > > return ($select_person_by_lname_array); > } > ------------------ > > Here is the problem: > > 1. $search_results in the HTML page is empty, so it seems that the array > I'm passing back from the function/class is not going through properly. > > 2. This line from the class: "if ($num_results > 0) { $this->valid = > "Y"; > } > else { $this->valid = "N"; }" in the class does not seem to work. > $this->valid is empty. There are results returned from the query... I > have > verified that, but I can't seem to assign a value to that variable. > > I have a feeling I'm just not doing something right, or not thinking > about objects properly. Any help would be greatly appreciated. Thanks > very much. > >

« previous php.general (#32993) next »