php - Return multiple row without the use of mysqlnd -
i dont have mysqlnd available, implemented helper function job:
public function bind_array($stmt, &$row) {
$md = $stmt->result_metadata(); var_dump($md); $params = array(); while($field = $md->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($stmt, 'bind_result'), $params); }
the trouble is, need able return multiple rows. of can return single row.
thanks....
edit: im aiming getting same result when calling mysqli fetch_assoc, not available me, dont have mysqlnd... array afterwards json_encoded ..
in fact, pdo way easier mysqli mysqlnd.
you can try my wrapper pdo can make better original class - it's incredible simple in use, combining simplicity of old mysql functions power , safety of prepared statements.
say, multiple results wull need one single line of code, opposite several screens in case of mysqli or half-dozen when using old mysql functions:
$sql = 'select return, fields table search_field = ?'; $data = db:prepare($sql)->execute([$search_val])->fetchall();
now $data contains desired result can iterate over
foreach ($data $row) { echo $row['fields']; }
just define 4 constants db credentials somewhere , you'll able use database anywhere in code, old mysql ext used be.
Comments
Post a Comment