我正在制作一个使用php和sql的大型网站,它将包含许多用户,我需要尽可能快地创建我的数据库。 这是得到所谓的上传数据库表中的职位价值,并将其存储在一个数组Sql高效快速搜索
//connect to database
$a = 'localhost';
$b = 'root';
$c = '';
$d = 'petsnote';
$connect = mysqli_connect($a, $b, $c, $d);
//get posts images variables
$images = array();
$cat = array();
$id = array();
//get posts info
if($connect){
$query = "SELECT * FROM `upload` WHERE `Active`='1'";
if($query_run = mysqli_query($connect, $query)){
while($get = mysqli_fetch_assoc($query_run)){
array_push($images, $get['Image_Name']);
array_push($cat, $get['PostCategory']);
array_push($id, $get['Id']);
}
$loop = count($images);
}
}
我从数据库中的所有职位信息,并将其存储在一个数组,并使用该阵列可以只查看一些代码价值.. 这是一种高效,专业和快速的方式来做事吗?
如果您只需要某些值,则应该让SQL仅返回这些值。使用'where'子句。 – chris85
如果你只使用一些值,那么你应该过滤你的SQL查询,只选择所需的值 – Tristan
我想使我的网站数据库查询尽可能快,即时通讯做了很多搜索,但我无法找到我想要的 –