retrieve variables in oop mvc

Viewed 22

Since I'm a beginner in coding, I am stuck in getting some variables from another file in OOP using MVC structure, here is my detailed situation:

I have Controllers AND Models for Users, Cars and auctions. I have also built some pages in the Views folder. In DB I have 5 tables for car, bid, auction, image and user. FYI, I have launched a session for the connected user.

When I want to display all available auctions, I get the perfect result for it using this query in the AuctionModel file:

public function all()
    {
    // getAll() is a function from DbAccess class
    return $this->getAll('
    SELECT * 
    FROM auction
    JOIN car
    ON auc_id = car_auc_id_fk
    JOIN image
    ON img_car_id_fk = car_id
    ');
}

and this code in the AuctionController file:

public function all()
    {
    $this->model->all());
    // here a code that leads to view page of all auctions
    } 

What I'd really like to do is retrieving one single auction based on the id of the auction, I did this in AuctionModel:

public function one($aucID)
    {
    // getOne() is a function from DbAccess class
    return $this->getOne("  
    SELECT * 
    FROM auction
    JOIN car
    ON auc_id = car_auc_id_fk
    JOIN image
    ON img_car_id_fk = car_id
    WHERE auc_id = :auc_id", 
    [':auc_id' => $aucID]
    );}

BUT.. I cannot pass a parameter to this method from the AuctionController file by doing the next code (I mean I cannot access auction ID from the controller):

    {
    $this->model->one($_POST['auc_id']));
    // here a code that leads to view page of one auction
    } 

Can you tell me how can I get the auc_id? I want to display one auction according to its ID.. voilĂ , thank you !

0 Answers
Related