本文整理汇总了PHP中PDO::lastErrorMsg方法的典型用法代码示例。如果您正苦于以下问题:PHP PDO::lastErrorMsg方法的具体用法?PHP PDO::lastErrorMsg怎么用?PHP PDO::lastErrorMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDO
的用法示例。
在下文中一共展示了PDO::lastErrorMsg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
/**
* Execute the SQL query.
*
* @param string $sql
* @throws Exception
* @return void
*/
public function query($sql)
{
if ($this->isPdo) {
$sth = $this->sqlite->prepare($sql);
if (!$sth->execute()) {
throw new Exception($sth->errorCode() . ': ' . $sth->errorInfo());
} else {
$this->result = $sth;
}
} else {
if (!($this->result = $this->sqlite->query($sql))) {
throw new Exception('Error: ' . $this->sqlite->lastErrorCode() . ': ' . $this->sqlite->lastErrorMsg() . '.');
}
}
}
示例2: isset
<?php
//$address = $_POST["address"]; //sql
$user = isset($_POST['user']) ? $_POST['user'] : '';
$host = isset($_POST['host']) ? $_POST['host'] : '';
$port = isset($_POST['port']) ? $_POST['port'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$change_password1 = isset($_POST['change_password1']) ? $_POST['change_password1'] : '';
if ($change_password1 == "change_password2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE mail_settings SET port='{$port}'") or die($db->lastErrorMsg());
$db->exec("UPDATE mail_settings SET host='{$host}'") or die($db->lastErrorMsg());
$db->exec("UPDATE mail_settings SET user='{$user}'") or die($db->lastErrorMsg());
$db->exec("UPDATE mail_settings SET password='{$password}'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<?php
$db = new PDO('sqlite:dbf/nettemp.db');
$sth = $db->prepare("select * from mail_settings ");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
?>
<table>
<tr>
示例3: isset
{
_log(__FILE__ . " - line " . __LINE__ . ": Connected to database");
}*/
_log(__FILE__ . " - line " . __LINE__ . ": " . isset($_REQUEST['oper']) ? $_REQUEST['oper'] : "No operation found!");
if (isset($_REQUEST['oper'])) {
try {
switch ($_REQUEST['oper']) {
case 'del':
_log(__FILE__ . " - line " . __LINE__ . ": Request for deletion: " . print_r($_REQUEST, TRUE));
// explode, then implode adding quotes
$deleteUUID = explode(",", utf8_decode($_REQUEST['id']));
$deleteParameters = '"' . implode('","', $deleteUUID) . '"';
if ($db->query("DELETE FROM Obstacles WHERE UUID IN (" . $deleteParameters . ")")) {
_log(__FILE__ . " - line " . __LINE__ . ": Obstacle(s) deleted: " . $deleteParameters);
} else {
_log(__FILE__ . " - line " . __LINE__ . ": Error deleting position(s) \"" . $deleteParameters . "\"! " . $db->lastErrorMsg());
exit(0);
}
break;
case 'edit':
updateRow();
break;
case 'add':
addRow();
// unsupported
break;
}
} catch (PDOException $e) {
_log(__FILE__ . " - line " . __LINE__ . ": Some query failed: " . PDO_PREFIX . SQLITE_DB_FILENAME . ": " . $e->getMessage());
exit(0);
// flag jQueryGrid that this failed
示例4: isset
<?php
$senderrors = isset($_POST['senderrors']) ? $_POST['senderrors'] : '';
$sende = isset($_POST['sende']) ? $_POST['sende'] : '';
if ($sende == "sende") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE mail_settings SET error='{$senderrors}' WHERE id='1'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<span class="belka">  Other <span class="okno">
<?php
$db = new PDO('sqlite:dbf/nettemp.db');
$sth = $db->prepare("select * from mail_settings ");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
?>
<form action="" method="post">
<td>Send readings errors</td>
<td><input type="checkbox" name="senderrors" value="on" <?php
echo $a['error'] == 'on' ? 'checked="checked"' : '';
?>
onclick="this.form.submit()" /></td>
<input type="hidden" name="sende" value="sende" />
</form>
<?php
}
?>
示例5: isset
<?php
$gpioad = isset($_POST['gpioad']) ? $_POST['gpioad'] : '';
$add = isset($_POST['add']) ? $_POST['add'] : '';
$gpio = isset($_POST['gpio']) ? $_POST['gpio'] : '';
if ($add == "ADD") {
$db = new PDO('sqlite:dbf/nettemp.db');
if (!empty($gpioad)) {
$db->exec("INSERT INTO gpio (gpio, name, status) VALUES ('{$gpio}','new_{$gpio}','OFF')") or die($db->lastErrorMsg());
} else {
$db->exec("DELETE FROM gpio WHERE gpio='{$gpio}'") or die($db->lastErrorMsg());
}
$db = NULL;
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<span class="belka">  Free gpio <span class="okno">
<?php
exec("/usr/local/bin/gpio -v |grep B+", $bplus);
exec("/usr/local/bin/gpio -v |grep 'Model B, Revision: 2'", $btwo);
exec("/usr/local/bin/gpio -v |grep 'Model B, Revision: 1'", $bone);
exec("/usr/local/bin/gpio -v |grep 'Model 2, Revision: 1.1'", $two);
if (!empty($bplus[0]) || !empty($two[0])) {
$gpiolist = array(4, 17, 27, 22, 5, 6, 13, 19, 26, 18, 23, 24, 25, 12, 16, 20, 21);
} elseif (!empty($btwo[0])) {
$gpiolist = array(4, 17, 27, 22, 18, 23, 24, 25, 28, 29, 30, 31);
} elseif (!empty($bone[0])) {
$gpiolist = array(4, 17, 27, 22, 18, 23, 24, 25);
} else {
$gpiolist = array(4, 17, 21, 22, 18, 23, 24, 25);
示例6: isset
<?php
$fw_onoff = isset($_POST['fw_onoff']) ? $_POST['fw_onoff'] : '';
$onoff = isset($_POST['onoff']) ? $_POST['onoff'] : '';
if ($onoff == "onoff") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE settings SET fw='{$fw_onoff}' WHERE id='1'") or die($db->lastErrorMsg());
if ($fw_onoff != "on") {
shell_exec("/bin/bash modules/security/fw/fw off");
}
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$db = new PDO('sqlite:dbf/nettemp.db');
$sth = $db->prepare("select * from settings ");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$fw = $a["fw"];
}
?>
<span class="belka">  Firewall settings<span class="okno">
<table>
<tr> <td><h2>Firewall</h2></td>
<form action="" method="post">
<td><input type="checkbox" name="fw_onoff" value="on" <?php
echo $fw == 'on' ? 'checked="checked"' : '';
示例7: PDO
?>
<?php
// SQLite - usuwanie alarmu
if (!empty($del_alarm) && $_POST['del_alarm1'] == "del_alarm2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE sensors SET alarm='off' WHERE id='{$del_alarm}'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<?php
if (!empty($tmp_id) && $_POST['ok'] == "ok") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE sensors SET tmp_min='{$tmp_min_new}' WHERE id='{$tmp_id}'") or die($db->lastErrorMsg());
$db->exec("UPDATE sensors SET tmp_max='{$tmp_max_new}' WHERE id='{$tmp_id}'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$triggernotice_checkbox = isset($_POST['triggernotice_checkbox']) ? $_POST['triggernotice_checkbox'] : '';
$xtriggernoticeon = isset($_POST['xtriggernoticeon']) ? $_POST['xtriggernoticeon'] : '';
if ($xtriggernoticeon == "xtriggernoticeON") {
//exec("/usr/local/bin/gpio reset $gpio_post ");
$db = new PDO('sqlite:dbf/nettemp.db') or die("cannot open the database");
$db->exec("UPDATE gpio SET trigger_notice='{$triggernotice_checkbox}' WHERE gpio='{$gpio_post}'") or die("exec error");
$db = NULL;
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
示例8: die
$db->exec("DELETE FROM sensors WHERE rom='{$usun_rom_nw}'") or die($db->lastErrorMsg());
//plik rrd
$rep_del_db = str_replace(" ", "_", $usun_rom_nw);
$name_rep_del_db = "{$rep_del_db}.rrd";
//echo $name_rep_del_db;
unlink("db/{$name_rep_del_db}");
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<?php
// SQLite - sekcja zmiany nazwy
if (!empty($name_new) && !empty($name_id) && $_POST['id_name2'] == "id_name3") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE sensors SET name='{$name_new}' WHERE id='{$name_id}'") or die($db->lastErrorMsg());
if (!empty($color)) {
$db->exec("UPDATE sensors SET color='{$color}' WHERE id='{$name_id}'") or die($db->lastErrorMsg());
}
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<?php
//read digitemrc file and 1-wire bus
foreach (glob("tmp/.digitemp*") as $file_digi) {
//$file_digi = "tmp/.digitemprc";
$file_digi2 = file($file_digi);
foreach ($file_digi2 as $line_digi) {
示例9: PDO
// SQLite - update
if ($notif_update1 == "notif_update2") {
$db = new PDO('sqlite:dbf/snmp.db');
$db->exec("UPDATE recipient SET sms_alarm='{$notif_update_sms}' WHERE id='{$notif_update}'") or die($db->lastErrorMsg());
$db->exec("UPDATE recipient SET mail_alarm='{$notif_update_mail}' WHERE id='{$notif_update}'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<?php
// SQLite - del
if (!empty($snmp_id) && $_POST['snmp_del1'] == "snmp_del2") {
$db = new PDO('sqlite:dbf/snmp.db');
$db->exec("DELETE FROM snmp WHERE id='{$snmp_id}'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<span class="belka">  Add sensor over SNMP<span class="okno">
<table>
<tr><td></td><td>name</td><td>community</td><td>host</td><td>OID</td><td>Divider</td></tr>
<tr>
<form action="" method="post">
<td></td>
<td><input type="text" name="snmp_name" size="10" value="" /></td>
<td><input type="text" name="snmp_community" size="7" value="" /></td>
<td><input type="text" name="snmp_host" size="7" value="" /></td>
示例10: exec
exec("sh modules/sms/sms_scan");
exec("rm tmp/gammu_identify");
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
// $dd = $_POST["dd"];
// if (!empty($dd) && ($_POST['dd1'] == "dd2") ){
// $db = new PDO('sqlite:dbf/nettemp.db');
// $db->exec("DELETE FROM sms_settings WHERE id='$dd'") or die ($db->lastErrorMsg());
// header("location: " . $_SERVER['REQUEST_URI']);
// exit();
// }
$sd = $_POST["sd"];
if ($_POST['sd1'] == "sd2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE sms_settings SET default_dev='off'") or die($db->lastErrorMsg());
$db->exec("UPDATE sms_settings SET default_dev='on' WHERE id='{$sd}'") or die($db->lastErrorMsg());
$sth = $db->prepare("SELECT * FROM sms_settings WHERE id='{$sd}'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $sdd) {
$ssd1 = $sdd['dev'];
$fh = fopen('tmp/gammurc', 'w');
fwrite($fh, "[gammu]\n");
fwrite($fh, "port={$ssd1}\n");
fwrite($fh, "connection=at\n");
fclose($fh);
}
exec("gammu -c tmp/gammurc identify > tmp/gammu_identify");
header("location: " . $_SERVER['REQUEST_URI']);
exit;
示例11: isset
<?php
$am_onoff = isset($_POST['am_onoff']) ? $_POST['am_onoff'] : '';
$onoff = isset($_POST['onoff']) ? $_POST['onoff'] : '';
if ($onoff == "onoff") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE settings SET authmod='{$am_onoff}' WHERE id='1'") or die($db->lastErrorMsg());
if ($am_onoff == "on") {
shell_exec("sudo lighttpd-enable-mod auth");
shell_exec("sudo service lighttpd reload");
}
if ($am_onoff != "on") {
shell_exec("sudo lighttpd-disable-mod auth");
shell_exec("sudo service lighttpd reload");
}
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$db = new PDO('sqlite:dbf/nettemp.db');
$sth = $db->prepare("select * from settings ");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$am = $a["authmod"];
}
?>
<span class="belka">  Authmod - WWW access <span class="okno">
<table>
示例12: isset
<?php
$test_mail = isset($_POST['test_mail']) ? $_POST['test_mail'] : '';
$mail_test1 = isset($_POST['mail_test1']) ? $_POST['mail_test1'] : '';
if ($mail_test1 == "mail_test2") {
$test_mail1 = escapeshellarg($test_mail);
$cmd = "modules/mail/mail_test {$test_mail1} 'Test from your nettemp device' 'Test mail from Your nettemp device.'";
shell_exec($cmd);
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE mail_settings SET test_mail='{$test_mail}'") or die($db->lastErrorMsg());
}
?>
<?php
$db = new PDO('sqlite:dbf/nettemp.db');
$sth = $db->prepare("select * from mail_settings ");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
?>
<table>
<tr>
<form action="settings" method="post">
<td>Send test mail to:</td>
<td><input type="text" name="test_mail" size="25" value="<?php
echo $a["test_mail"];
?>
" /></td>
<input type="hidden" name="mail_test1" value="mail_test2" />
<td><input type="image" src="media/ico/Actions-edit-redo-icon.png" /></td>
示例13: header
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$ss_onoff = isset($_POST['ss_onoff']) ? $_POST['ss_onoff'] : '';
$ss_onoff1 = isset($_POST['ss_onoff1']) ? $_POST['ss_onoff1'] : '';
if ($ss_onoff1 == "ss_onoff2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE settings SET sms='{$ss_onoff}' WHERE id='1'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$ms_onoff = isset($_POST['ms_onoff']) ? $_POST['ms_onoff'] : '';
$ms_onoff1 = isset($_POST['ms_onoff1']) ? $_POST['ms_onoff1'] : '';
if ($ms_onoff1 == "ms_onoff2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE settings SET mail='{$ms_onoff}' WHERE id='1'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
$db = new PDO('sqlite:dbf/nettemp.db');
$sth = $db->prepare("select * from settings WHERE id='1'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$rrd = $a["rrd"];
$hc = $a["highcharts"];
$ss = $a["sms"];
$ms = $a["mail"];
$gpio = $a["gpio"];
$lcd = $a["lcd"];
}
示例14: isset
$notif_update1 = isset($_POST['notif_update1']) ? $_POST['notif_update1'] : '';
if ($notif_update1 == "notif_update2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE recipient SET sms_alarm='{$notif_update_sms}' WHERE id='{$notif_update}'") or die($db->lastErrorMsg());
$db->exec("UPDATE recipient SET mail_alarm='{$notif_update_mail}' WHERE id='{$notif_update}'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<?php
// SQLite - usuwanie notification
if (!empty($notif_del) && $_POST['notif_del1'] == "notif_del2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("DELETE FROM recipient WHERE id='{$notif_del}'") or die($db->lastErrorMsg());
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<span class="belka">  Add user<span class="okno">
<table>
<tr>
<td><img src="media/ico/User-Preppy-Blue-icon.png"> Name</td>
<td><img src="media/ico/message-icon.png"> Email</td>
<td><img src="media/ico/phone-blue-glow-icon.png"> Telephone</td>
<td><img src="media/ico/message-icon.png"></td>
<td><img src="media/ico/phone-blue-glow-icon.png"></td>
<td></td>
示例15: PDO
if (!empty($smsc) && $_POST['smsc1'] == "smsc2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE sms_settings SET smsc='{$smsc}' WHERE default_dev='on'") or die($db->lastErrorMsg());
$set_smsc = "gammu -c tmp/gammurc setsmsc 1 {$smsc}";
shell_exec($set_smsc);
header("location: " . $_SERVER['REQUEST_URI']);
exit;
}
?>
<?php
$sms_test = $_POST["sms_test"];
if ($_POST['sms_test1'] == "sms_test2") {
$db = new PDO('sqlite:dbf/nettemp.db');
$db->exec("UPDATE sms_settings SET sms_test='{$sms_test}' WHERE default_dev='on'") or die($db->lastErrorMsg());
$cmd = "modules/sms/sms_test";
shell_exec($cmd);
}
?>
<?php
$db = new PDO('sqlite:dbf/nettemp.db');
$sth = $db->prepare("select * from sms_settings WHERE default_dev='on' ");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
?>
<table><tr>
<form action="" method="post">