本文整理汇总了PHP中JDatabase::loadResult方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabase::loadResult方法的具体用法?PHP JDatabase::loadResult怎么用?PHP JDatabase::loadResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabase
的用法示例。
在下文中一共展示了JDatabase::loadResult方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNextOrder
/**
* Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.
* This is useful for placing a new item last in a group of items in the table.
*
* @param string $where WHERE clause to use for selecting the MAX(ordering) for the table.
*
* @return mixed Boolean false an failure or the next ordering value as an integer.
*
* @link http://docs.joomla.org/JTable/getNextOrder
* @since 11.1
*/
public function getNextOrder($where = '')
{
// If there is no ordering field set an error and return false.
if (!property_exists($this, 'ordering')) {
$e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_CLASS_DOES_NOT_SUPPORT_ORDERING', get_class($this)));
$this->setError($e);
return false;
}
// Get the largest ordering value for a given where clause.
$query = $this->_db->getQuery(true);
$query->select('MAX(ordering)');
$query->from($this->_tbl);
if ($where) {
$query->where($where);
}
$this->_db->setQuery($query);
$max = (int) $this->_db->loadResult();
// Check for a database error.
if ($this->_db->getErrorNum()) {
$e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_GET_NEXT_ORDER_FAILED', get_class($this), $this->_db->getErrorMsg()));
$this->setError($e);
return false;
}
// Return the largest ordering value + 1.
return $max + 1;
}
示例2: count
/**
* Count items.
*
* @return int
*/
public function count()
{
$query = clone $this->query;
$this->build($query);
$query->select('COUNT(*)');
$this->db->setQuery($query);
$count = (int) $this->db->loadResult();
KunenaError::checkDatabaseError();
return $count;
}
示例3: getNextOrder
/**
* Returns the ordering value to place a new item last in its group
*
* @access public
* @param string query WHERE clause for selecting MAX(ordering).
*/
function getNextOrder($where = '')
{
if (!in_array('ordering', array_keys($this->getProperties()))) {
$this->setError(get_class($this) . ' does not support ordering');
return false;
}
$query = 'SELECT MAX(ordering)' . ' FROM ' . $this->_tbl . ($where ? ' WHERE ' . $where : '');
$this->_db->setQuery($query);
$maxord = $this->_db->loadResult();
if ($this->_db->getErrorNum()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
return $maxord + 1;
}
示例4: indexExists
/**
* Controlla l'esistenza di un indice in una tabella
* @param string $tablename
* @param string indexname
* @return boolean TRUE se esiste, FALSE se non esiste
*/
public function indexExists($tablename, $indexname)
{
$q = "SHOW INDEX FROM `" . $this->replacePrefix($tablename) . "` WHERE Key_name='" . $indexname . "'";
$this->db->setQuery($q);
return $this->db->loadResult() != null;
}
示例5: loadResult
/**
* This method loads the first field of the first row returned by the query.
*
* @return string|null The value returned in the query or null if the query failed.
*
* @throws \RuntimeException
*/
public function loadResult()
{
return $this->_db->loadResult();
}
示例6: getPagination
public function getPagination($total = null)
{
if (empty($total)) {
$this->db->setQuery('SELECT count(*)' . ' FROM #__acctexp_' . $this->table . $this->getConstraints());
$total = $this->db->loadResult();
}
return new bsPagination($total, $this->state->limitstart, $this->state->limit);
}
示例7: queryResult
/**
* Execute a query to the database and load the result returned
*
* The result returned by this method is the same as the one returned by JDatabase::loadResult()
* Basically, it returns the result (single field) of a database operation
* Generally used for SELECT field operations
*
* @param string $query The query to be executed
*
* @return mixed The result of the query
*
* @throws RuntimeException
*
* @since 1.0.0
*/
public function queryResult($query)
{
// query database table
$this->_database->setQuery($query);
return $this->_database->loadResult();
}
示例8: listRecords
//.........这里部分代码省略.........
}
if(JFactory::getSession()->get('bfStatus', '') == 'exported')
{
$ands .= "record.exported = 1 And";
}
else
if(JFactory::getSession()->get('bfStatus', '') == 'archived')
{
$ands .= "record.archived = 1 And";
}
else
if(JFactory::getSession()->get('bfStatus', '') == 'viewed')
{
$ands .= "record.viewed = 1 And";
}
if($ands != '')
{
$ands = 'Where ' . substr($ands,0,strlen($ands)-4);
}
$limiter = " Limit $offset, $limit";
if($limit == 0)
{
$limiter = '';
}
$this->db->setQuery("Select Distinct SQL_CALC_FOUND_ROWS record.* From #__facileforms_records As record $subs $ands Order By record.".JRequest::getWord('orderBy','submitted')." ".(JRequest::getWord('order','DESC') == 'DESC' ? 'ASC' : 'DESC').$limiter);
$rows = $this->db->loadObjectList();
//echo $this->db->getQuery();
$this->db->setQuery("SELECT FOUND_ROWS();");
$foundRows = $this->db->loadResult();
jimport('joomla.html.pagination');
$pagination = new JPagination($foundRows, $offset, $limit);
$this->db->setQuery("Select Distinct form As id, `name`, title From #__facileforms_records Order By title");
$forms = $this->db->loadObjectList();
$size = count($forms);
$formsArray = array();
for($i = 0;$i < $size;$i++)
{
if(!isset($formsArray['_'.$forms[$i]->id])){
$formsArray['_'.$forms[$i]->id] = $forms[$i];
}
}
$forms = $formsArray;
?>
<script type="text/javascript">
var bf_submitbutton = function(pressbutton)
{
var form = document.adminForm;
switch (pressbutton) {
case 'remove':
case 'exportCsv':
case 'exportXls':
case 'exportPdf':
case 'exportXml':
if (form.boxchecked.value==0) {
alert("<?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_PLSSELECTRECS'); ?>");
return;
} // if
form.exportt.value = 1;
break;
示例9: store
/**
* Inserts a new row if id is zero or updates an existing row in the database table
*
* Can be overloaded/supplemented by the child class
*
* @access public
* @param boolean If false, null object variables are not updated
* @return null|string null if successful otherwise returns and error message
*/
function store($updateNulls = true)
{
$k = $this->_tbl_key;
$wheres = array();
// execute query and retrieve result
$query = $this->_db->getQuery(true);
$query->select(' 1 ');
$query->from(' ' . $this->_db->quoteName($this->_tbl) . ' ');
// check whether all fields are filled and build where statement
for ($i = 0; $i < count($k); $i++) {
if ($this->{$k}[$i] === null) {
$this->setError(get_class($this) . '::store failed - primary key ' . $this->{$k} . ' is empty (null)');
return false;
} else {
$wheres[] = ' ' . $this->_db->quoteName($k[$i]) . ' = ' . $this->_db->Quote($this->{$k}[$i]) . ' ';
}
}
foreach ($wheres as $where) {
$query->where($where);
}
$this->_db->setQuery($query);
$result = $this->_db->loadResult();
// if query has no result, record does not exists yet and is added here
// if query has result, record exists and is updated here
if (!$result) {
$ret = $this->_db->insertObject($this->_tbl, $this);
} else {
$query->clear();
$query->update($this->_db->quoteName($this->_tbl));
$sets = array();
foreach ($this->getProperties() as $name => $value) {
if (is_array($value) or is_object($value) or $name[0] == '_') {
// internal or NA field
continue;
}
if (in_array($name, $k)) {
// PK not to be updated
continue;
}
if ($value === null) {
if ($updateNulls) {
$val = 'NULL';
} else {
continue;
}
} else {
//$val = $this->_db->isQuoted( $name ) ? $this->_db->Quote( $value ) : (int) $value;
$val = $this->_db->Quote($value);
}
$sets[] = $this->_db->quoteName($name) . '=' . $val;
}
if (count($sets) > 0) {
foreach ($sets as $set) {
$query->set($set);
}
foreach ($wheres as $where) {
$query->where($where);
}
$this->_db->setQuery($query);
$ret = $this->_db->query();
} else {
$ret = true;
}
}
if (!$ret) {
$this->setError(get_class($this) . '::store failed - ' . $this->_db->getErrorMsg());
return false;
} else {
return true;
}
}