1 回答
TA贡献1829条经验 获得超4个赞
您可以像此示例一样获取结果,然后使用 array_merge
$mysqli = new mysqli('localhost', 'root', '', 'test');
$manual = array(
[ 'id' => 9 , 'first_name' => 'John9' , 'last_name' => 'Doe9'] ,
[ 'id' => 19 , 'first_name' => 'John19' , 'last_name' => 'Doe19']
);
$sql = " SELECT * from users ";
$result = $mysqli -> query($sql);
$rows = $result -> fetch_all(MYSQLI_ASSOC);
$results = array_merge($manual , $rows);
结果会是这样的
Array
(
[id] => 9
[first_name] => John9
[last_name] => Doe9
)
Array
(
[id] => 19
[first_name] => John19
[last_name] => Doe19
)
Array
(
[id] => 1
[first_name] => John
[last_name] => Doe
)
Array
(
[id] => 2
[first_name] => John3
[last_name] => Doe
)
Array
(
[id] => 4
[first_name] => John4
[last_name] => Doe
)
- 1 回答
- 0 关注
- 113 浏览
添加回答
举报