0

我想知道是否有人可以告诉我如何索引我所做的 MySQL 查询。从只有 120 行的数据库加载需要很长时间。

我的查询是:

 $sql = "SELECT firstname, lastname, email, phone, username, password, status, 
memberview, statuschangedate FROM csvdata ORDER BY lastname ";

$sth= $DBH->prepare($sql);
$sth->execute();

while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
code
}

感谢您的时间!

已编辑----------

这是实际发生的事情 -

   $sql = "SELECT firstname, lastname, email, phone, username, password, status, memberview, statuschangedate FROM csvdata ORDER BY lastname ";
   $sth= $DBH->prepare($sql);
   $sth->execute();
   $i = 0;
                                echo "<table class='alltable'> 
                                      <tr class='firsttr' style='background:gray;'>
                                      <td>First Name </td>
                                      <td>Last Name </td>
                                      <td>Email </td>
                                      <td>Phone </td>
                                      <td>Username </td>
                                      <td>Password </td>
                                      <td>Status </td>
                                      <td>Memberview</td>
                                      <td>Status Change Date</td>
                                      <td>#</td>
                                      </tr>

                                        ";
                                        $j = 0;
                                while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
                                    $csvfirst = $row;
                                    $csvfirstname = $csvfirst['firstname'];
                                    $csvlastname = $csvfirst['lastname'];
                                    $csvemail = $csvfirst['email'];
                                    $csvphone = $csvfirst['phone'];
                                    $csvusername = $csvfirst['username'];
                                    $csvpassword= $csvfirst['password'];
                                    $csvstatus = $csvfirst['status'];
                                    $csvmemberview = $csvfirst['memberview'];
                                    $csvstatuschange = $csvfirst['statuschangedate'];

                                        $memberfirstnamearray[$j]  = $csvfirstname;
                                    $memberlastnamearray[$j]  = $csvlastname;
                                    $memberemailarray[$j]  = $csvemail;
                                    $memberphonearray[$j]  = $csvphone;
                                    $j++;
                                $i++;

                                    echo "
                                            <tr> 
                                        <td>
                                        $csvfirstname
                                        </td>
                                        <td>
                                        $csvlastname
                                        </td>
                                        <td>
                                        $csvemail
                                        </td>
                                        <td>
                                        $csvphone
                                        </td>
                                        <td>
                                        $csvusername
                                        </td>
                                        <td>
                                        $csvpassword
                                        </td>
                                        <td>
                                        $csvstatus
                                        </td>
                                        <td>
                                        $csvmemberview
                                        </td>
                                        <td>
                                        $csvstatuschange
                                        </td>
                                        <td>
                                        $i
                                        </td>

                                      </tr>
                                    ";

                                }
                                $_SESSION['firstnameexport'] = $memberfirstnamearray;
                                $_SESSION['lastnameexport'] = $memberlastnamearray;
                                $_SESSION['emailexport'] = $memberemailarray;
                                $_SESSION['phoneexport'] = $memberphonearray;
                                $_SESSION['num'] = $j;
                                echo "
                                      </table>";

                }

因此,它从数据库中抓取了大约 120 名员工,加载大约需要 20 秒。我将这张表包含在div一个按钮中,一旦你给它计时,jquery 就会visibility: none变为可见并向下滑动。

需要帮助请叫我!

已编辑----------

从使用 desc csvdata - 这是永远占用的员工。

    'id', 'int(11)', 'NO', 'PRI', NULL, 'auto_increment'
'firstname', 'varchar(105)', 'YES', '', NULL, ''
'lastname', 'varchar(105)', 'YES', '', NULL, ''
'email', 'varchar(105)', 'YES', '', NULL, ''
'phone', 'varchar(105)', 'YES', '', NULL, ''
'username', 'varchar(105)', 'YES', '', NULL, ''
'password', 'varchar(105)', 'YES', '', NULL, ''
'status', 'varchar(105)', 'YES', '', NULL, ''
'memberview', 'varchar(105)', 'YES', '', NULL, ''
'statuschangedate', 'varchar(105)', 'YES', '', NULL, ''
'notes', 'varchar(1000)', 'YES', '', NULL, ''
'customernotes', 'varchar(1000)', 'YES', '', NULL, ''
4

1 回答 1

0

嘿,伙计们,你们知道是什么问题吗?

是 JQuery slidedown() 延迟了它,所以我只是切换它以将 css 更改为 display: table 并且工作完美!

代码 -

<script>
$(".viewall").click(function () {

    //dropdown.bind('change', function(){   
    //$(".alltable").slideDown(0,function(){
    //});
    $(".alltable").css("display", "table");
    $(".alltable tr").css("display", "table-row");
    $(".alltable td").css("display", "table-cell");
    //$(".alltable tr").slideDown(0,function(){
    //});
    //$(".alltable td").slideDown(0,function(){
    //});
});
$(".closeall").click(function () {

    //dropdown.bind('change', function(){   
    /*$(".alltable").slideUp(200,function(){
    });*/
    $(".alltable").css("display", "none");
    $(".alltable tr").css("display", "none");
    $(".alltable td").css("display", "none");
    /*$(".alltable tr").slideUp(200,function(){
    });
    $(".alltable td").slideUp(200,function(){
    });*/
});

</script>
于 2012-09-30T20:21:31.633 回答