本文整理汇总了PHP中dbFetchOne函数的典型用法代码示例。如果您正苦于以下问题:PHP dbFetchOne函数的具体用法?PHP dbFetchOne怎么用?PHP dbFetchOne使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbFetchOne函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($IdOrRow)
{
$row = NULL;
if ($IdOrRow) {
if (is_integer($IdOrRow) or is_numeric($IdOrRow)) {
$row = dbFetchOne('SELECT *,unix_timestamp(StartTime) as Time FROM Events WHERE Id=?', NULL, array($IdOrRow));
if (!$row) {
Error("Unable to load Event record for Id=" . $IdOrRow);
}
} elseif (is_array($IdOrRow)) {
$row = $IdOrRow;
} else {
Error("Unknown argument passed to Event Constructor ({$IdOrRow})");
return;
}
}
# end if isset($IdOrRow)
if ($row) {
foreach ($row as $k => $v) {
$this->{$k} = $v;
}
} else {
Error("No row for Event " . $IdOrRow);
}
}
示例2: __construct
public function __construct($IdOrRow)
{
$row = NULL;
if ($IdOrRow) {
if (is_integer($IdOrRow) or is_numeric($IdOrRow)) {
$row = dbFetchOne('SELECT * FROM Monitors WHERE Id=?', NULL, array($IdOrRow));
if (!$row) {
Error("Unable to load Server record for Id=" . $IdOrRow);
}
} elseif (is_array($IdOrRow)) {
$row = $IdOrRow;
} else {
Error("Unknown argument passed to Monitor Constructor ({$IdOrRow})");
return;
}
}
# end if isset($IdOrRow)
if ($row) {
foreach ($row as $k => $v) {
$this->{$k} = $v;
}
if ($this->{'Controllable'}) {
$s = dbFetchOne('SELECT * FROM Controls WHERE Id=?', NULL, array($this->{'ControlId'}));
foreach ($s as $k => $v) {
if ($k == 'Id') {
continue;
}
$this->{$k} = $v;
}
}
} else {
Error("No row for Monitor " . $IdOrRow);
}
}
示例3: getUserDefaultPresetId
function getUserDefaultPresetId($userId)
{
$query = "SELECT * FROM Users WHERE Id='{$userId}'";
$result = dbFetchOne($query);
if (array_key_exists('defaultPreset', $result)) {
return $result['defaultPreset'];
} else {
return false;
}
}
示例4: total
function total()
{
$sql = "select count(id) total from " . $this->table;
$data = dbFetchOne($sql);
return isset($data['total']) ? $data['total'] : false;
if (!$this->db->simple_query($sql)) {
logCreate('sql:' . $sql . '|' . $this->db->error(), 'error');
return false;
} else {
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
$row = $query->row_array();
return $row['total'];
}
}
return false;
}
示例5: __construct
public function __construct($IdOrRow = NULL)
{
$row = NULL;
if ($IdOrRow) {
if (is_integer($IdOrRow) or is_numeric($IdOrRow)) {
$row = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, array($IdOrRow));
if (!$row) {
Error("Unable to load Storage record for Id=" . $IdOrRow);
}
} elseif (is_array($IdOrRow)) {
$row = $IdOrRow;
}
}
if ($row) {
foreach ($row as $k => $v) {
$this->{$k} = $v;
}
} else {
$this->{'Name'} = '';
$this->{'Path'} = '';
}
}
示例6: dbId
function dbId($name = "id", $start = 10, $counter = 1)
{
$CI =& get_instance();
$CI->load->dbforge();
if ($name == '') {
$name = 'id';
}
if ($name != 'id') {
$name .= "_id";
} else {
}
if (!$CI->db->table_exists($name)) {
$CI->dbforge->add_field('id');
$CI->dbforge->create_table($name, TRUE);
$str = $CI->db->last_query();
logConfig("create table:{$str}", 'logDB');
} else {
}
$CI->db->reset_query();
$sql = "select count(id) c, max(id) max from {$name}";
$data = dbFetchOne($sql);
if ($data['c'] == 0) {
$data = array('id' => $start);
$sql = $CI->db->insert_string($name, $data);
dbQuery($sql, 1);
$num = $start;
} else {
$num = $data['max'] + $counter;
$where = "id=" . $data['max'];
$data = array('id' => $num);
$sql = $CI->db->update_string($name, $data, $where);
dbQuery($sql, 1);
}
$str = $CI->db->last_query();
logConfig("dbId sql:{$str}", 'logDB');
$CI->db->reset_query();
return $num;
}
示例7: validHtmlStr
return;
}
if (empty($_REQUEST['mode'])) {
if (canStream()) {
$mode = "stream";
} else {
$mode = "still";
}
} else {
$mode = validHtmlStr($_REQUEST['mode']);
}
$group = '';
$groupSql = '';
if (!empty($_REQUEST['group'])) {
$group = validInt($_REQUEST['group']);
$row = dbFetchOne('SELECT * FROM Groups WHERE Id = ?', NULL, array($group));
$groupSql = " and find_in_set( Id, '" . $row['MonitorIds'] . "' )";
}
$sql = "SELECT * FROM Monitors WHERE Function != 'None'{$groupSql} ORDER BY Sequence";
$monitors = array();
$monIdx = 0;
foreach (dbFetchAll($sql) as $row) {
if (!visibleMonitor($row['Id'])) {
continue;
}
if (isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid']) {
$monIdx = count($monitors);
}
$row['ScaledWidth'] = reScale($row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
$row['ScaledHeight'] = reScale($row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
$monitors[] = $row;
示例8: validInt
$view = "error";
return;
}
$eid = validInt($_REQUEST['eid']);
if (!empty($_REQUEST['fid'])) {
$fid = validInt($_REQUEST['fid']);
}
$sql = "select E.*,M.Name as MonitorName,M.Width,M.Height,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = '" . dbEscape($eid) . "'";
$event = dbFetchOne($sql);
if (!empty($fid)) {
$sql = "select * from Frames where EventId = '" . dbEscape($eid) . "' and FrameId = '" . dbEscape($fid) . "'";
if (!($frame = dbFetchOne($sql))) {
$frame = array('FrameId' => $fid, 'Type' => 'Normal', 'Score' => 0);
}
} else {
$frame = dbFetchOne("select * from Frames where EventId = '" . dbEscape($eid) . "' and Score = '" . $event['MaxScore'] . "'");
}
$maxFid = $event['Frames'];
$firstFid = 1;
$prevFid = $frame['FrameId'] - 1;
$nextFid = $frame['FrameId'] + 1;
$lastFid = $maxFid;
$alarmFrame = $frame['Type'] == 'Alarm';
if (isset($_REQUEST['scale'])) {
$scale = validInt($_REQUEST['scale']);
} else {
$scale = max(reScale(SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE), SCALE_BASE);
}
$imageData = getImageSrc($event, $frame, $scale, isset($_REQUEST['show']) && $_REQUEST['show'] == "capt");
$imagePath = $imageData['thumbPath'];
$eventPath = $imageData['eventPath'];
示例9: exportFileList
function exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc)
{
if (canView('Events') && $eid) {
$sql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.Width,M.Height,E.Name,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ?';
$event = dbFetchOne($sql, NULL, array($eid));
$eventPath = ZM_DIR_EVENTS . '/' . mygetEventPath($event);
$files = array();
if ($dir = opendir($eventPath)) {
while (($file = readdir($dir)) !== false) {
if (is_file($eventPath . "/" . $file)) {
$files[$file] = $file;
}
}
closedir($dir);
}
$exportFileList = array();
if ($exportDetail) {
$file = "zmEventDetail.html";
if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
Fatal("Can't open event detail export file '{$file}'");
}
fwrite($fp, exportEventDetail($event, $exportFrames, $exportImages));
fclose($fp);
$exportFileList[$file] = $eventPath . "/" . $file;
}
if ($exportFrames) {
$file = "zmEventFrames.html";
if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
Fatal("Can't open event frames export file '{$file}'");
}
fwrite($fp, exportEventFrames($event, $exportDetail, $exportImages));
fclose($fp);
$exportFileList[$file] = $eventPath . "/" . $file;
}
if ($exportImages) {
$filesLeft = array();
$myfilelist = array();
foreach ($files as $file) {
if (preg_match("/-(?:capture|analyse).jpg\$/", $file)) {
$exportFileList[$file] = $eventPath . "/" . $file;
$myfilelist[$file] = $eventPath . "/" . $file;
} else {
$filesLeft[$file] = $file;
}
}
$files = $filesLeft;
// create an image slider
if (!empty($myfilelist)) {
$file = "zmEventImages.html";
if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
Fatal("Can't open event images export file '{$file}'");
}
fwrite($fp, exportEventImages($event, $exportDetail, $exportFrames, $myfilelist));
fclose($fp);
$exportFileList[$file] = $eventPath . "/" . $file;
}
}
if ($exportVideo) {
$filesLeft = array();
foreach ($files as $file) {
if (preg_match("/\\.(?:mpg|mpeg|avi|asf|3gp)\$/", $file)) {
$exportFileList[$file] = $eventPath . "/" . $file;
} else {
$filesLeft[$file] = $file;
}
}
$files = $filesLeft;
}
if ($exportMisc) {
foreach ($files as $file) {
$exportFileList[$file] = $eventPath . "/" . $file;
}
$files = array();
}
}
return array_values($exportFileList);
}
示例10: dbFetchOne
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if (!canView('Stream')) {
$view = "error";
return;
}
$groupSql = "";
if (!empty($_REQUEST['group'])) {
$row = dbFetchOne('select * from Groups where Id = ?', NULL, array($_REQUEST['group']));
$sql = "select * from Monitors where Function != 'None' and find_in_set( Id, '" . $row['MonitorIds'] . "' ) order by Sequence";
} else {
$sql = "select * from Monitors where Function != 'None' order by Sequence";
}
$maxWidth = 0;
$maxHeight = 0;
$showControl = false;
$index = 0;
$monitors = array();
foreach (dbFetchAll($sql) as $row) {
if (!visibleMonitor($row['Id'])) {
continue;
}
if (isset($_REQUEST['scale'])) {
$scale = validInt($_REQUEST['scale']);
示例11: dbFetchOne
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if (isset($_SESSION['user'])) {
if (!isset($_POST['view'])) {
$_POST['view'] = "playback";
}
$response = dbFetchOne("SELECT * FROM Users WHERE Id={$_SESSION['user']['Id']} LIMIT 1");
if (!$response) {
$error = "ERROR: Failed to fully autheticate user, please contact your system administrator!";
} elseif (isset($_SESSION['user']['Username'])) {
header("Location: ?view={$_POST['view']}");
}
}
xhtmlHeaders(__FILE__, $SLANG['Login']);
?>
<body class="zm">
<div class="view-wrapper"> <!-- begin view-wrapper -->
<div class="container">
<form name="loginForm" id="loginForm" method="post" class="form-signin" action="<?php
echo $_SERVER['PHP_SELF'];
示例12: dbEscape
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if (!canView('Stream')) {
$view = "error";
return;
}
$groupSql = "";
if (!empty($_REQUEST['group'])) {
$sql = "select * from Groups where Id = '" . dbEscape($_REQUEST['group']) . "'";
$row = dbFetchOne($sql);
$groupSql = " and find_in_set( Id, '" . $row['MonitorIds'] . "' )";
}
$sql = "select * from Monitors where Function != 'None'{$groupSql} order by Sequence";
$maxWidth = 0;
$maxHeight = 0;
$showControl = false;
$index = 0;
$monitors = array();
foreach (dbFetchAll($sql) as $row) {
if (!visibleMonitor($row['Id'])) {
continue;
}
if (isset($_REQUEST['scale'])) {
$scale = validInt($_REQUEST['scale']);
} else {
示例13: foreach
foreach (dbFetchAll(escapeSql($eventsSql)) as $event) {
xml_tag_sec("EVENT", 1);
xml_tag_val("ID", $event['Id']);
xml_tag_val("NAME", $event['Name']);
xml_tag_val("TIME", strftime(STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime'])));
xml_tag_val("DURATION", $event['Length']);
xml_tag_val("FRAMES", $event['Frames']);
xml_tag_val("FPS", $event['Length'] > 0 ? ceil($event['Frames'] / $event['Length']) : 0);
xml_tag_val("TOTSCORE", $event['TotScore']);
xml_tag_val("AVGSCORE", $event['AvgScore']);
xml_tag_val("MAXSCORE", $event['MaxScore']);
/* Grab the max frame-id from Frames table. If AlarmFrames = 0, don't try
* to grab any frames, and just signal the max frame index as index 0 */
$fridx = 1;
$alarmFrames = 1;
if ($event['AlarmFrames']) {
$framesSql = "select FrameId from Frames where (Type = 'Alarm') and (EventId = " . $event['Id'] . ") order by Score desc limit 1";
$fr = dbFetchOne($framesSql);
$fridx = $fr['FrameId'];
$alarmFrames = $event['AlarmFrames'];
}
xml_tag_val("ALARMFRAMES", $alarmFrames);
xml_tag_val("MAXFRAMEID", $fridx);
xml_tag_sec("EVENT", 0);
}
}
xml_tag_sec("EVENTS", 0);
xml_tag_sec("MONITOR", 0);
}
xml_tag_sec("MONITOR_LIST", 0);
xml_tag_sec("ZM_XML", 0);
示例14: dbEscape
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if (!canView('Events')) {
$view = "error";
return;
}
$sql = "select E.*,M.Name as MonitorName,M.Width,M.Height from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = '" . dbEscape($_REQUEST['eid']) . "'";
$event = dbFetchOne($sql);
$sql = "select *, unix_timestamp( TimeStamp ) as UnixTimeStamp from Frames where EventID = '" . dbEscape($_REQUEST['eid']) . "' order by FrameId";
$frames = dbFetchAll($sql);
$focusWindow = true;
xhtmlHeaders(__FILE__, $SLANG['Frames'] . " - " . $event['Id']);
?>
<body>
<div id="page">
<div id="header">
<div id="headerButtons"><a href="#" onclick="closeWindow();"><?php
echo $SLANG['Close'];
?>
</a></div>
<h2><?php
echo $SLANG['Frames'];
?>
示例15: dbFetchOne
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if (!canView('Stream')) {
$_REQUEST['view'] = "error";
return;
}
$imagesPerLine = 2;
$sql = "select * from Groups where Name = 'Mobile'";
$group = dbFetchOne($sql);
$sql = "select * from Monitors where Function != 'None' order by Sequence";
$monitors = array();
$maxWidth = 0;
$maxHeight = 0;
foreach (dbFetchAll($sql) as $row) {
if (!visibleMonitor($row['Id'])) {
continue;
}
if ($group && $group['MonitorIds'] && !in_array($row['Id'], explode(',', $group['MonitorIds']))) {
continue;
}
if ($maxWidth < $row['Width']) {
$maxWidth = $row['Width'];
}
if ($maxHeight < $row['Height']) {