static function find($recipe_id, $dbh) { $stmt = $dbh->prepare("select * from " . Steps::$tableName . " WHERE recipe_id = :id ORDER BY stepno ASC "); $stmt->bindParam(":id", $recipe_id); $stmt->execute(); $result = array(); while ($row = $stmt->fetch()) { $p = new Steps(); $p->copyFromRow($row); $result[] = $p; } return $result; }
function copyStepsFromRow($row) { if (isset($row['step'])) { $arr = array(); $i = 1; foreach ($row['step'] as $key => $value) { if ($value != "") { $x = array("recipe_id" => $this->id, "stepno" => $i, "text" => $value); $n = new Steps(); $n->copyFromRow($x); array_push($arr, $n); $i++; } } $this->steps = $arr; } }