我将缩短从服务器获取的 PHP。我正在使用 SSP 帮助程序类文件:
//rest of code up here
require( 'ssp.class.php' );
echo json_encode(
SSP::complex( $_GET, $sql_details, $table, $primaryKey, $columns, $where, "business_name != 'xyzcompany'")
);
这很好用。
但是,我想根据用户输入动态替换“xyzcompany”。为了安全起见,我想使用 PDO。我通常知道如何使用 PDO,但现在我如何将其折叠到这个数据表示例中。我已经读到 SSP 帮助程序处理 PDO,我只是找不到如何使用它的文档。例如伪代码:
//rest of code up here
require( 'ssp.class.php' );
$business_name = $_POST['biz']; //supplied by user in text input
:biz_name = $business_name; //I know this isn't correct syntax
echo json_encode(
SSP::complex( $_GET, $sql_details, $table, $primaryKey, $columns, $where, "business_name != :biz_name")
);
最佳答案
使用下面的代码:
# Obtain an PHP PDO connection from a connection details array
$db = SSP::db($sql_details);
echo json_encode(
SSP::complex($_GET, $sql_details, $table, $primaryKey, $columns, $where, "business_name != ".$db->quote($business_name))
);
关于php - 使用 PDO 的服务器端数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36579783/