With the usual MySqli I can do:
$the_year=$_GET['y'];
$rslt=$db->query("SELECT * FROM cars where year=$the_year");
while($oAuto=$rslt->fetch_object('MyCarClass')) {
doSomething($oAuto);
}
But, I would like to do something like this (parts omitted):
$stmt->prepare('SELECT * FROM cars WHERE year=?');
... bind_param(..);
$stmt->bind_result($oCar);
while (stmt->execute()) {
$stmt->fetch();
.....
}
Is that possible? If so, where would I put my class name -- in the first param of bind_result?
Or perhaps $oCar= fetch('MyCar')?
Or???
TIA,
Pete
Fetching an object using mysqli prepared statements
Moderator: General Moderators
-
PeteClimbs
- Forum Newbie
- Posts: 2
- Joined: Sun Aug 23, 2009 9:33 am
- Location: Saranac Lake, New York