douxiong5972 2016-03-20 11:58
浏览 46

用php改进搜索算法mysql

I have the following code in php that does a search for all the columns within the table set

# list all columns from a table with a SHOW COLUMNS FROM
if(count($user_table_columns)) {
# If you have
foreach($_POST["contacts_form_a"] as $contacts_form_a => $form_a) {
    # create two arrays, a changing the spaces to lines and putting everything in lowercase
    # These viéram information to a form that the user can choose the names of the tables
    $array_form_a[] = str_replace(" ", "_", strtolower($form_a));
    $array_form_a_index[] = $form_a; }
    foreach($user_table_columns as $user_columns => $columns) {
        # create an array with all the table columns
        $array_columns[] = str_replace(" ", "_", strtolower($columns["Field"]));
   }
}

foreach($array_form_a as $index => $value) {
    # Here it will check whether the data from the array in the array are two a
    unset($checked);
    if(in_array($value, $array_columns)) {
        # compare the data of two arrays to create the condition
        $checked = true;
    }
    if(isset($checked)) {
        # If the column exists in the table, it inserts the information from the form
        echo "INSERT INTO $usr_ ADD $value COMMENT " . $array_form_a_index[$index] . "<br>";
    } else {
        # If the column does not exist in the table, it creates the column after insert information
        echo "ALTER TABLE $usr_ ADD $value COMMENT " . $array_form_a_index[$index] . "<br>";
        /* insert into */
    }

}

Is there a correct way to do this or this way is correct?

I wonder if there is how to improve this algorithm if it is in the wrong ways and or slow, for example, two arrays with the exchange of spaces for line and another without the Exchange and one that ensures the user writing and one that changes to the table, done in the right way?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用