I'm trying to fetch all rows for parentId for my form. However my below code isn't able to fetches just 1 record, into my array:
public function getChildByParent($parentId)
{
$stmt = $this->conn->prepare("SELECT childId, nick, relation FROM childId WHERE parentId = ?");
$stmt->bind_param("s", $parentId);
$stmt->execute();
$stmt->bind_result($childId, $nick, $relation);
$stmt->fetch();
$user = array();
$user['childId'] = $childId;
$user['nick'] = $nick;
$user['relation'] = $relation;
return $user;
}
I understand that I need to tweek around $stmt->fetch() and $user = array() to fetch_all. Can you help me work around this code?
Appreciate your efforts.