All pastes #498988 Raw Edit

php dao

public text v1 · immutable
·published 2007-05-20 20:21 UTC
rendered paste body
public function loadAll()
    {

        $sql = "SELECT * 
		FROM `help_category`";

        $result = mysql_query($sql);

        if (!$result)
        {
            echo "Could not successfully run query ($sql) from DB: " . mysql_error();
            exit;
        }

        $helpCategories = array();

        if (empty($result))
        {
            echo "No rows found";
            // HelpCategories array remains empty
        }
        else
        {
            while ($row = mysql_fetch_assoc($result))
            {
                //construct a new HelpCategory
                $helpCategory = new HelpCategory($row["help_category_id"], $row["name"]);

@@                print_r($helpCategory);

                // add new HelpCategory to arary                
                $helpCategories[$i++]->$helpCategory;
@@                print_r($helpCategories[$i]);
            }
        }

        // release database resources
        mysql_free_result($result);

        // return retrieved HelpCategories
        return $helpCategories;
    }