<i id='LrJWp'><tr id='LrJWp'><dt id='LrJWp'><q id='LrJWp'><span id='LrJWp'><b id='LrJWp'><form id='LrJWp'><ins id='LrJWp'></ins><ul id='LrJWp'></ul><sub id='LrJWp'></sub></form><legend id='LrJWp'></legend><bdo id='LrJWp'><pre id='LrJWp'><center id='LrJWp'></center></pre></bdo></b><th id='LrJWp'></th></span></q></dt></tr></i><div id='LrJWp'><tfoot id='LrJWp'></tfoot><dl id='LrJWp'><fieldset id='LrJWp'></fieldset></dl></div>

<small id='LrJWp'></small><noframes id='LrJWp'>

  • <tfoot id='LrJWp'></tfoot>

  • <legend id='LrJWp'><style id='LrJWp'><dir id='LrJWp'><q id='LrJWp'></q></dir></style></legend>
      <bdo id='LrJWp'></bdo><ul id='LrJWp'></ul>

      1. MySQLi 中的 SELECT * FROM

        时间:2023-07-31
          <tbody id='wVl6f'></tbody>

      2. <tfoot id='wVl6f'></tfoot>
      3. <legend id='wVl6f'><style id='wVl6f'><dir id='wVl6f'><q id='wVl6f'></q></dir></style></legend>
          <bdo id='wVl6f'></bdo><ul id='wVl6f'></ul>

        • <i id='wVl6f'><tr id='wVl6f'><dt id='wVl6f'><q id='wVl6f'><span id='wVl6f'><b id='wVl6f'><form id='wVl6f'><ins id='wVl6f'></ins><ul id='wVl6f'></ul><sub id='wVl6f'></sub></form><legend id='wVl6f'></legend><bdo id='wVl6f'><pre id='wVl6f'><center id='wVl6f'></center></pre></bdo></b><th id='wVl6f'></th></span></q></dt></tr></i><div id='wVl6f'><tfoot id='wVl6f'></tfoot><dl id='wVl6f'><fieldset id='wVl6f'></fieldset></dl></div>

                <small id='wVl6f'></small><noframes id='wVl6f'>

                • 本文介绍了MySQLi 中的 SELECT * FROM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的网站相当广泛,我最近才切换到 PHP5(称我为大器晚成的人).

                  My site is rather extensive, and I just recently made the switch to PHP5 (call me a late bloomer).

                  我之前所有的 MySQL 查询都是这样构建的:

                  All of my MySQL query's before were built as such:

                  "SELECT * FROM tablename WHERE field1 = 'value' && field2 = 'value2'";
                  

                  这使它变得非常容易、简单和友好.

                  This made it very easy, simple and friendly.

                  出于明显的安全原因,我现在正在尝试切换到 mysqli,并且我很难弄清楚如何在 bind_param<时实现相同的 SELECT * FROM 查询/code> 需要特定参数.

                  I am now trying to make the switch to mysqli for obvious security reasons, and I am having a hard time figuring out how to implement the same SELECT * FROM queries when the bind_param requires specific arguments.

                  这句话是过去式了吗?

                  如果是,我该如何处理涉及大量列的查询?我真的需要每次都把它们都打出来吗?

                  If it is, how do I handle a query with tons of columns involved? Do I really need to type them all out every time?

                  推荐答案

                  "SELECT * FROM tablename WHERE field1 = 'value' && field2 = 'value2'";
                  

                  变成

                  "SELECT * FROM tablename WHERE field1 = ? && field2 = ?";
                  

                  传递给 $mysqli::prepare:

                  $stmt = $mysqli->prepare(
                    "SELECT * FROM tablename WHERE field1 = ? && field2 = ?");
                  $stmt->bind_param( "ss", $value, $value2); 
                  // "ss' is a format string, each "s" means string
                  $stmt->execute();
                   
                  $stmt->bind_result($col1, $col2);
                  // then fetch and close the statement
                  

                  OP 评论:

                  所以如果我有 5 个参数,我可能会有sssis"或其他东西(取决于输入的类型?)

                  so if i have 5 parameters, i could potentially have "sssis" or something (depending on the types of inputs?)

                  对,准备好的语句中每个 ? 参数都有一个类型说明符,所有这些都是位置说明符(第一个说明符适用于第一个 ? ,它被第一个实际参数(哪个是 bind_param)) 的第二个参数.

                  Right, one type specifier per ? parameter in the prepared statement, all of them positional (first specifier applies to first ? which is replaced by first actual parameter (which is the second parameter to bind_param)).

                  这篇关于MySQLi 中的 SELECT * FROM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                • <small id='2gkXx'></small><noframes id='2gkXx'>

                  <i id='2gkXx'><tr id='2gkXx'><dt id='2gkXx'><q id='2gkXx'><span id='2gkXx'><b id='2gkXx'><form id='2gkXx'><ins id='2gkXx'></ins><ul id='2gkXx'></ul><sub id='2gkXx'></sub></form><legend id='2gkXx'></legend><bdo id='2gkXx'><pre id='2gkXx'><center id='2gkXx'></center></pre></bdo></b><th id='2gkXx'></th></span></q></dt></tr></i><div id='2gkXx'><tfoot id='2gkXx'></tfoot><dl id='2gkXx'><fieldset id='2gkXx'></fieldset></dl></div>
                    <tbody id='2gkXx'></tbody>
                    <bdo id='2gkXx'></bdo><ul id='2gkXx'></ul>

                    1. <legend id='2gkXx'><style id='2gkXx'><dir id='2gkXx'><q id='2gkXx'></q></dir></style></legend>
                        1. <tfoot id='2gkXx'></tfoot>