Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You store them in the model (Grab them from DB), you pull them with the controller (On page load), and you show the result of them in the View (By calling the controller class when needed).</p> <p>This is the basic theory of MVC...</p> <p>Good luck!</p> <p>I will give you a simple example of a car object that can be sold... this example sucks, but you can understand from it how MVC works...</p> <pre><code>&lt;? // Data class Car { private $_color; public function setColor($newC) { $this-&gt;_color = $newC; } public function getColor() { return $this-&gt;_color; } private $_maxSpeed public function setMaxSpeed($newMS) { $this-&gt;_maxSpeed = $newMS; } public function getMaxSpeed() { return $this-&gt;maxSpeed; } } // Example $car = new Car(); $car-&gt;setColor($dbInfo['color']); $car-&gt;setMaxSpeed($dbInfo['maxSpeed']); // Controller class Sales { . . . public function SaleCar(Costumer $costumer, Car $car, $quantity) { if($car-&gt;getColor() == "red") // Red is expensive color... $car-&gt;MultiplyPriceBy(1.5); // Just an example... else $car-&gt;SubsetQuantityBy($quantity); // The car has quantity propery as well... and so on... $costumer-&gt;setPaymentType("Credit-card"); . . . $costumer-&gt;Pay($quantity * $car-&gt;getPrice()); return $finalPrice; // $quantity * $car-&gt;getPrice() } . . . } // View class SalesPanel { . . . public function output() { foreach($this-&gt;cars as $car) { if(in_array($car-&gt;getID(), $_POST['car_id'])) Sales-&gt;SaleCar(Costumer::GetCostumerFromID($_SESSION['uid']), $car, $_POST['quanityty']); } $output = . . . $output .= "Car model GHi675 old by . . . "; // Get info from controller } . . . } </code></pre> <p>?></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload