/** * Perform a query on the database and return the first field value only. * * It adds the `LIMIT 1` clause if the query has no record limit * This will be useful for `COUNT()`, `MAX()`, `MIN()` queries * * @param string $sql The SQL query string * @param array $args The array of placeholders and their values * * array( * ':placeholder1' => $value1, * ':placeholder2' => $value2 * ) * * @return mixed The value of the first field */ function db_fetch($sql, $args = array()) { if (!preg_match('/LIMIT\\s+[0-9]{1,}\\b/i', $sql)) { $sql .= ' LIMIT 1'; } if ($result = db_query($sql, $args)) { if ($row = db_fetchArray($result)) { return $row[0]; } } return false; }
/** * Perform a query on the database and fetch one field only * * @return mixed The result * If the result not found, return null. */ public function fetch() { $this->limit(1); if ($this->result === null) { $this->execute(); } if ($this->result && ($row = db_fetchArray($this->result))) { return $row[0]; } return null; }
// +---------------------------------------------------------------------------+ // require_once '../lib-common.php'; $usermodeUID = $_USER['uid'] > 1 ? $_USER['uid'] : 1; $project_id = COM_applyFilter($_GET['id'], true); $actionurl = $_CONF['site_url'] . '/nexflow/index.php'; $rowid = 1; $fromprojectlink = true; if ($nomenu == 1 or $_GET['singleuse'] == 1) { echo COM_siteHeader('none'); } else { echo COM_siteHeader('menu'); } $query = DB_query("SELECT description,wf_process_id FROM {$_TABLES['nf_projects']} WHERE id='{$project_id}'"); if (DB_numRows($query) == 1) { list($title, $processid) = db_fetchArray($query); echo COM_startBlock("View Project Detail for: <span style=\"color:red;\">{$title}</span>", '', 'blockheader.thtml'); $p = new Template($_CONF['path_layout'] . 'nexflow/taskconsole'); $p->set_file('javascript', 'javascript/taskconsole.thtml'); $p->set_var('site_url', $_CONF['site_url']); $p->set_var('layout_url', $_CONF['layout_url']); $p->set_var('num_records', 1); $p->parse('output', 'javascript'); echo $p->finish($p->get_var('output')); echo LB . '<script type="text/javascript" src="' . $_CONF['site_url'] . '/nexflow/include/ajaxsupport.js"></script>'; echo LB . '<div id="projectdetail_rec1">'; include 'projectdetails.php'; echo '<table width="90%" style="margin-left:5px;margin-top:10px;">'; echo '<tr id="taskdetail_rec1"><td class="pd_projects_row1">'; echo $projectdetails; echo '<td></td></tr></table></div>';