Using variable in function created by another function
Posted: Thu Jan 13, 2011 6:14 pm
I am trying to write a function that queries a database based on using a MySQL entry ID as its argument and then using the contents of the resulting array of that query in another function.
Here is the code I have... I'm trying to figure out how to make it so I can use the $results variable from the db_edit function to create separate variables for each array row in the get_info function.
Any advice would be GREATLY appreciated... THanks
Here is the code I have... I'm trying to figure out how to make it so I can use the $results variable from the db_edit function to create separate variables for each array row in the get_info function.
Any advice would be GREATLY appreciated... THanks
Code: Select all
<?php
class basics{
public function db_edit($object_id){
require('connection.php');
$query = "select * from table where id = '".$object_id"' limit 0, 1";
$results = $db->query($query);
$db->disconnect();
}
public function get_info($category, $object_id){
require('connection.php');
$info_query = new basics();
$info_query->db_edit(4);
$row = &$results->fetchrow(MDB2_FETCHMODE_ASSOC);
$object_title = $row['object_title_field'];
$db->disconnect();
}
}
?>