php - mysql Join produces an error -
i have code, , cant find error.
public function show(){ $x=null; $owner = $_session['uid']; $sql = "select kunde.name n1, rechnung.rechnr rnr `rechnung`as rr inner join `kunde` on rr.kid = kunde.kid owner = ? "; $stmt = $this->mysqli->prepare($sql); $stmt->bind_param("i", $owner); $stmt->execute(); $result = $stmt->get_result(); while ($obj = $result->fetch_object()) { $x[] = $obj; } return $x;
}
without join result join got these message don t know why: call member function bind_param() on non-object
thx reading.
you've got rewrite sql statement , use alias name field rechnr
too. instead of rechnung.rechnr
you've got use rr.rechnr
instead:
$sql = "select kunde.name n1, rr.rechnr rnr `rechnung` rr inner join `kunde` on rr.kid = kunde.kid owner = ? ";
because didn't use alias name, preparing of statement did fail.
Comments
Post a Comment