public function getAllUserPlants($user) { $db = new Db(); $plants = array(); $id = $user->getId(); $results = $db->select("SELECT * from plants WHERE user_id = {$id}"); foreach ($results as $result) { $plant = new Plant(); $plant->hydrate($result); $plants[] = $plant; } return $plants; }
$arr = array(); $arr["id"] = isset($_GET["id"]) ? $_GET["id"] : ''; $arr["name"] = isset($_GET["name"]) ? $_GET["name"] : ''; $arr["location"] = isset($_GET["location"]) ? $_GET["location"] : ''; $arr["longitude"] = isset($_GET["longitude"]) ? $_GET["longitude"] : ''; $arr["latitude"] = isset($_GET["latitude"]) ? $_GET["latitude"] : ''; // $arr["weather_id"] = isset($_GET["weather_id"])?$_GET["weather_id"]:''; // $arr["soilid_id"] = isset($_GET["soilid_id"])?$_GET["soilid_id"]:''; $arr["weather"] = isset($_GET["weather"]) ? $_GET["weather"] : ''; $arr["soil"] = isset($_GET["soil"]) ? $_GET["soil"] : ''; $arr["temperature"] = isset($_GET["temperature"]) ? $_GET["temperature"] : ''; $arr["wind"] = isset($_GET["wind"]) ? $_GET["wind"] : ''; $arr["humidity"] = isset($_GET["humidity"]) ? $_GET["humidity"] : ''; $arr["notes"] = isset($_GET["notes"]) ? $_GET["notes"] : ''; $plant = new Plant(); $plant->hydrate($arr); $userManager->savePlant($plant); // var_dump($plant); $target = $_SESSION['current_user']; $userManager = new UserManager(); $plants = $userManager->getAllUserPlants($target); include '../views/user_plants.php'; break; case 'add_flora': //$userManager = new UserManager(); //$plant = new Plant(); include '../views/user_add_plant.php'; break; case 'geo_finder': //$userManager = new UserManager(); //$plant = new Plant();