Is there any Good Tutorial on Class

Discussion in 'PHP' started by discuss4u, Dec 7, 2007.

  1. #1
    Hi, I would like to know if there is any comprehensive tutorial ans examples on using class to manipulate MYSQL database. I have found some on the net but what these tutorials give are simple manipulations which only return one row of results.

    Thanks for help!
     
    discuss4u, Dec 7, 2007 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    To return multiple rows, in most cases you will need to do a "while" loop.

    
    $sql = new db();
    while ($row = $sql->db_Fetch()) {
    	echo $row['column'];
    }
    
    Code (php):
    This is example of the e107 mysql class, this should work for most other class, as it's structure depends on php mysql.
     
    Kaizoku, Dec 7, 2007 IP
  3. discuss4u

    discuss4u Well-Known Member

    Messages:
    846
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Thanks, but then it can only returns one column. In fact, what I usually do is something like that. Say there are two columns, one is the url of a website and one is the website name. Is there an class such that I can get all the arrays of
     
    discuss4u, Dec 7, 2007 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    I think your sql only selects one column, what you want is
    SELECT * FROM table_name
    or
    SELECT col1, col2 FROM table_name
     
    Kaizoku, Dec 7, 2007 IP
  5. discuss4u

    discuss4u Well-Known Member

    Messages:
    846
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    #5
    I think I understand what you mean. Let me do a quite study on that. Thanks!
     
    discuss4u, Dec 8, 2007 IP