本文整理汇总了PHP中SSP::fatal方法的典型用法代码示例。如果您正苦于以下问题:PHP SSP::fatal方法的具体用法?PHP SSP::fatal怎么用?PHP SSP::fatal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSP
的用法示例。
在下文中一共展示了SSP::fatal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sql_exec
/**
* Execute an SQL query on the database
*
* @param resource $db Database handler
* @param array $bindings Array of PDO binding values from bind() to be
* used for safely escaping strings. Note that this can be given as the
* SQL query string if no bindings are required.
* @param string $sql SQL query to execute.
* @return array Result from the query (all rows)
*/
static function sql_exec($db, $bindings, $sql = null)
{
// Argument shifting
if ($sql === null) {
$sql = $bindings;
}
$stmt = $db->prepare($sql);
//echo $sql;
// Bind parameters
if (is_array($bindings)) {
for ($i = 0, $ien = count($bindings); $i < $ien; $i++) {
$binding = $bindings[$i];
$stmt->bindValue($binding['key'], $binding['val'], $binding['type']);
}
}
// Execute
try {
$stmt->execute();
} catch (PDOException $e) {
SSP::fatal("An SQL error occurred: " . $e->getMessage());
}
// Return all
return $stmt->fetchAll();
}
示例2: sql_exec
/**
* Execute an SQL query on the database
*
* @param resource $db Database handler
* @param array $bindings Array of PDO binding values from bind() to be
* used for safely escaping strings. Note that this can be given as the
* SQL query string if no bindings are required.
* @param string $sql SQL query to execute.
* @return array Result from the query (all rows)
*/
static function sql_exec($conn, $bindings, $sql = null)
{
try {
if ($sql === null) {
$rs = $conn->Execute($bindings);
return $rs->getArray();
} else {
$rs = $conn->Execute($sql, $bindings);
return $rs->getArray();
}
} catch (Exception $e) {
SSP::fatal("An SQL error occurred: " . $e->getMessage());
}
}