View Single Post
ישן 06-05-09, 12:48   # 1
Shillo
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
הודעות: 509

Shillo לא מחובר  

בעיה עם מחלקה בPHP

יש לי מחלקה שמנהלת מסד נתונים, עכשיו יש פעולה פנימית כזו:
קוד:
public function select($table, $rows = '*', $where = null, $order = null)
    {
        $q = 'SELECT '.$rows.' FROM '.$table;
        if($where != null)
            $q .= ' WHERE '.$where;
        if($order != null)
            $q .= ' ORDER BY '.$order;

        $query = @mysql_query($q);
        if($query)
        {
            $this->numResults = mysql_num_rows($query);
            for($i = 0; $i < $this->numResults; $i++)
            {
                $r = mysql_fetch_array($query);
                $key = array_keys($r);
                for($x = 0; $x < count($key); $x++)
                {
                    // Sanitizes keys so only alphavalues are allowed
                    if(!is_int($key[$x]))
                    {
                        if(mysql_num_rows($query) > 1)
                            $this->result[$i][$key[$x]] = $r[$key[$x]];
                        else if(mysql_num_rows($query) < 1)
                            $this->result = null;
                        else
                            $this->result[$key[$x]] = $r[$key[$x]];
                    }
                }
            }
            return true;
        }
        else
        {
            return false;
        }
    }

ואז קראתי למחלקה בדף אחר, ואם אני כותב:
קוד:
$res = $msgs->getResult();
print_r ($res);

וזה מציג לי את התכנים של המערך.
אבל אם אני עושה echo $res הוא מדפיס "Array".
מה שאני רוצה בעצם זה ש echo $res ידפיס את כל התכנים של המערך.
  Reply With Quote