Click here to Skip to main content
16,020,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am new to object oriented programming in PHP and i want to know how to handle MySQL logic through objects and properties instead of using direct column values by using getters and setters.


PHP
$stmt = $this->db_connect()->prepare('SELECT * FROM product_list where type="dvd" ORDER BY ID');
        $stmt->execute();
        $stmt2 = $this->db_connect()->prepare('SELECT size FROM dvd');
        $stmt2->execute();
while($size = $stmt2->fetch()){
            while($row = $stmt->fetch()){
            echo '<div class="product">'.
            '<input type="checkbox" class="delete-checkbox" name="check[]" value ="'. $row['ID'].'">';
            echo '<p>'.$row['sku']. '<br>' .$row['name']. '<br>'.$row['price'].'$'.' <br>'.$size['size'].'MB'.'</p>';
            echo '</div>';
        } 
     }


What I have tried:

how can i use getters and setters instead of direct column values and could I be provided with an example just so I can grasp the concept thank you.
Posted
Updated 10-Sep-21 5:25am

1 solution

This is the Quick Answers forum, there is not space to teach you either the principles of OOP, or the specifics of PHP and MySQL. Google will find you extensive materials on all the subjects.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900