http://php.morva.net/manual/en/mysqli-stmt.bind-result.phpの次のコードは、mysqli クエリが準備および実行されていることを示しています。while ($stmt->fetch()) ループは、結果リソースを生成しているように見えます。これを変更して、関数への呼び出しを含めることはできますか?
while ($stmt->fetch()) {
foreach($row as $key => $val)
{
$c[$key] = performFunction($val);
}
$result[] = $c;
}
次に、print_r($result) の代わりに return($result) を返します。そうすれば、 $val の値を動的に変更できます
元のコード =
if ($stmt = $mysqli->prepare("SELECT * FROM sample WHERE t2 LIKE ?")) {
$tt2 = '%';
$stmt->bind_param("s", $tt2);
$stmt->execute();
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field())
{
$params[] = &$row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $params);
while ($stmt->fetch()) {
foreach($row as $key => $val)
{
$c[$key] = $val;
}
$result[] = $c;
}
$stmt->close();
}
$mysqli->close();
print_r($result);
これは機能しますか、他にどのようにこれを行うことができますか?
皆さんありがとう...