代码之家  ›  专栏  ›  技术社区  ›  zaczap

使用OCI预览PHP中准备好的SQL语句?

  •  4
  • zaczap  · 技术社区  · 14 年前

    好奇您是否可以准备一个语句,绑定它,然后预览生成的SQL,如下所示 函数是占位符):

    // Glorious declaration of a non-specific query
    $statment = oci_parse($handle, "SELECT x FROM y WHERE variable = :value");
    
    // Bind up some variables
    oci_bind_by_name($statement, ':value', $value);
    ...
    
    // Location of interest
    oci_preview_sql($statement); // ? is there some method like this?    
    
    // Execute it
    oci_execute($statement, OCI_DEFAULT);
    
    1 回复  |  直到 14 年前
        1
  •  3
  •   Wrikken    14 年前

    为什么? prepared语句是防止SQL注入的好工具。

    推荐文章