本文整理汇总了PHP中display_db_error函数的典型用法代码示例。如果您正苦于以下问题:PHP display_db_error函数的具体用法?PHP display_db_error怎么用?PHP display_db_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了display_db_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_course
function add_course($course_name, $course_short_name, $course_desc, $teacher_id, $course_nbr, $room, $course_type_cde)
{
global $db;
$query = 'INSERT INTO course
(course_name, course_short_name, course_desc, teacher_id,
course_nbr, room, course_type_cde, active)
VALUES
(:course_name, :course_short_name, :course_desc, :teacher_id,
:course_nbr, :room, :course_type_cde, 1)';
try {
$statement = $db->prepare($query);
$statement->bindValue(':course_name', $course_name);
$statement->bindValue(':course_short_name', $course_short_name);
$statement->bindValue(':course_desc', $course_desc);
$statement->bindValue(':teacher_id', $teacher_id);
$statement->bindValue(':course_nbr', $course_nbr);
$statement->bindValue(':room', $room);
$statement->bindValue(':course_type_cde', $course_type_cde);
$statement->execute();
$statement->closeCursor();
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例2: add_payment
function add_payment($payment)
{
global $db;
$query = 'INSERT INTO payments
(orderID, amount, paymentDateTime, cardTypeID, cardNumber, cardExpMonth, cardExpYear)
VALUES
(:orderID, :amount, sysdate(), :cardTypeID, :cardNumber, :cardExpMonth, :cardExpYear)';
try {
$statement = $db->prepare($query);
$statement->bindValue(':orderID', $payment['orderID']);
$statement->bindValue(':amount', $payment['amount']);
$statement->bindValue(':cardTypeID', $payment['cardTypeID']);
$statement->bindValue(':cardNumber', $payment['cardNumber']);
$statement->bindValue(':cardExpMonth', $payment['cardExpMonth']);
$statement->bindValue(':cardExpYear', $payment['cardExpYear']);
$statement->execute();
$statement->closeCursor();
// Get the last product ID that was automatically generated
$payment_id = $db->lastInsertId();
return $payment_id;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例3: get_category
function get_category($category_id)
{
global $db;
$category_id_esc = $db->escape_string($category_id);
$query = "SELECT * FROM categories\n WHERE categoryID = '{$category_id_esc}'";
$result = $db->query($query);
if ($result == false) {
display_db_error($db->error);
}
$category = $result->fetch_assoc();
$result->free();
return $category;
}
示例4: is_valid_admin_login
function is_valid_admin_login($email, $password)
{
global $db;
try {
$password = sha1($email . $password);
$query = "SELECT userID FROM jobs_user\n WHERE email = '{$email}' AND password = '{$password}'";
$statement = $db->query($query);
$valid = $statement->rowcount();
return $statement;
} catch (PDOException $e) {
display_db_error($e->getMessage());
}
}
示例5: delete_category
function delete_category($category_id)
{
global $db;
$query = 'DELETE FROM categories WHERE categoryID = :category_id';
try {
$statement = $db->prepare($query);
$statement->bindValue(':category_id', $category_id);
$statement->execute();
$statement->closeCursor();
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例6: get_user
function get_user($userName)
{
global $db;
$query = 'SELECT * FROM users WHERE userName = :userName';
try {
$statement = $db->prepare($query);
$statement->bindValue(':userName', $userName);
$statement->execute();
$result = $statement->fetch();
$statement->closeCursor();
return $result;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例7: get_category
function get_category($category_id)
{
global $db;
$query = 'SELECT * FROM categories
WHERE categoryID = :category_id';
try {
$statement = $db->prepare($query);
$statement->bindValue(':category_id', $category_id);
$statement->execute();
$result = $statement->fetch();
$statement->closeCursor();
return $result;
} catch (PDOException $e) {
display_db_error($e->getMessage());
}
}
示例8: get_product
function get_product($product_id)
{
global $db;
$query = '
SELECT * FROM Products p';
try {
$statement = $db->prepare($query);
$statement->bindValue(':product_id', $product_id);
$statement->execute();
$result = $statement->fetch();
$statement->closeCursor();
return $result;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例9: update_card_type
function update_card_type($type)
{
global $db;
$query = 'UPDATE cardtypes
SET description = :description
WHERE cardTypeId = :type_id';
try {
$statement = $db->prepare($query);
$statement->bindValue(':type_id', $type['cardTypeID']);
$statement->bindValue(':description', $type['description']);
$row_count = $statement->execute();
$statement->closeCursor();
return $row_count;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例10: smf_db_initiate
/**
* Maps the implementations in this file (smf_db_function_name)
* to the $smcFunc['db_function_name'] variable.
* @see Subs-Db-mysql.php#smf_db_initiate
*/
function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, &$db_prefix, $db_options = array())
{
global $smcFunc, $mysql_set_mode;
// Map some database specific functions, only do this once.
if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'postg_fetch_assoc') {
$smcFunc += array('db_query' => 'smf_db_query', 'db_quote' => 'smf_db_quote', 'db_insert' => 'smf_db_insert', 'db_insert_id' => 'smf_db_insert_id', 'db_fetch_assoc' => 'smf_db_fetch_assoc', 'db_fetch_row' => 'smf_db_fetch_row', 'db_free_result' => 'pg_free_result', 'db_num_rows' => 'pg_num_rows', 'db_data_seek' => 'smf_db_data_seek', 'db_num_fields' => 'pg_num_fields', 'db_escape_string' => 'pg_escape_string', 'db_unescape_string' => 'smf_db_unescape_string', 'db_server_info' => 'smf_db_version', 'db_affected_rows' => 'smf_db_affected_rows', 'db_transaction' => 'smf_db_transaction', 'db_error' => 'pg_last_error', 'db_select_db' => 'smf_db_select_db', 'db_title' => 'PostgreSQL', 'db_sybase' => true, 'db_case_sensitive' => true, 'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string');
}
if (!empty($db_options['persist'])) {
$connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'');
} else {
$connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'');
}
// Something's wrong, show an error if its fatal (which we assume it is)
if (!$connection) {
if (!empty($db_options['non_fatal'])) {
return null;
} else {
display_db_error();
}
}
return $connection;
}
示例11: smf_db_initiate
/**
* Maps the implementations in this file (smf_db_function_name)
* to the $smcFunc['db_function_name'] variable.
*/
function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
{
global $smcFunc, $mysql_set_mode, $db_in_transact, $sqlite_error;
// Map some database specific functions, only do this once.
if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'sqlite_fetch_array') {
$smcFunc += array('db_query' => 'smf_db_query', 'db_quote' => 'smf_db_quote', 'db_fetch_assoc' => 'sqlite_fetch_array', 'db_fetch_row' => 'smf_db_fetch_row', 'db_free_result' => 'smf_db_free_result', 'db_insert' => 'smf_db_insert', 'db_insert_id' => 'smf_db_insert_id', 'db_num_rows' => 'sqlite_num_rows', 'db_data_seek' => 'sqlite_seek', 'db_num_fields' => 'sqlite_num_fields', 'db_escape_string' => 'sqlite_escape_string', 'db_unescape_string' => 'smf_db_unescape_string', 'db_server_info' => 'smf_db_libversion', 'db_affected_rows' => 'smf_db_affected_rows', 'db_transaction' => 'smf_db_transaction', 'db_error' => 'smf_db_last_error', 'db_select_db' => '', 'db_title' => 'SQLite', 'db_sybase' => true, 'db_case_sensitive' => true, 'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string');
}
if (substr($db_name, -3) != '.db') {
$db_name .= '.db';
}
if (!empty($db_options['persist'])) {
$connection = @sqlite_popen($db_name, 0666, $sqlite_error);
} else {
$connection = @sqlite_open($db_name, 0666, $sqlite_error);
}
// Something's wrong, show an error if its fatal (which we assume it is)
if (!$connection) {
if (!empty($db_options['non_fatal'])) {
return null;
} else {
display_db_error();
}
}
$db_in_transact = false;
// This is frankly stupid - stop SQLite returning alias names!
@sqlite_query('PRAGMA short_column_names = 1', $connection);
// Make some user defined functions!
sqlite_create_function($connection, 'unix_timestamp', 'smf_udf_unix_timestamp', 0);
sqlite_create_function($connection, 'inet_aton', 'smf_udf_inet_aton', 1);
sqlite_create_function($connection, 'inet_ntoa', 'smf_udf_inet_ntoa', 1);
sqlite_create_function($connection, 'find_in_set', 'smf_udf_find_in_set', 2);
sqlite_create_function($connection, 'year', 'smf_udf_year', 1);
sqlite_create_function($connection, 'month', 'smf_udf_month', 1);
sqlite_create_function($connection, 'dayofmonth', 'smf_udf_dayofmonth', 1);
sqlite_create_function($connection, 'concat', 'smf_udf_concat');
sqlite_create_function($connection, 'locate', 'smf_udf_locate', 2);
sqlite_create_function($connection, 'regexp', 'smf_udf_regexp', 2);
return $connection;
}
示例12: get_course_list
function get_course_list()
{
global $db;
$query = 'SELECT course.course_id, course_name, course_short_name, course_desc, course_type_desc, teacher.display_name, course_section.section_nbr, GET_SCHEDULE_TIMES_LIST (course_section.section_id) as times
from course
inner join course_type
on course.course_type_cde = course_type.course_type_cde
inner join course_section
on course.course_id = course_section.course_id
inner join teacher
on teacher.teacher_id = course_section.teacher_id
where course.active = 1
and course_section.active = 1';
try {
$statement = $db->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$statement->closeCursor();
return $result;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例13: add_data3
function add_data3($id, $answer)
{
global $db;
try {
$query = 'insert into `RMproject`.`set7`(id,Answer) values (:id, :answer)';
$statement = $db->prepare($query);
$statement->bindValue(':id', $id);
$statement->bindValue(':answer', $answer);
$statement->execute();
$statement->closeCursor();
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例14: delete_location
function delete_location($locationID)
{
global $db;
$query = 'UPDATE locations SET status=\'R\' WHERE locationID = :location_id';
try {
$statement = $db->prepare($query);
$statement->bindValue(':location_id', $locationID);
$row_count = $statement->execute();
$statement->closeCursor();
return $row_count;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
示例15: get_teacher
function get_teacher($teacher_id)
{
global $db;
$query = 'SELECT teacher_id, last_name, first_name, display_name
from teacher
where teacher_id = :teacher_id';
try {
$statement = $db->prepare($query);
$statement->bindValue(':teacher_id', $teacher_id);
$statement->execute();
$result = $statement->fetch();
$statement->closeCursor();
return $result;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}