本文整理汇总了PHP中JDatabase::getErrorNum方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabase::getErrorNum方法的具体用法?PHP JDatabase::getErrorNum怎么用?PHP JDatabase::getErrorNum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabase
的用法示例。
在下文中一共展示了JDatabase::getErrorNum方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canDelete
/**
* Generic check for whether dependencies exist for this object in the database schema
*
* Can be overloaded/supplemented by the child class
*
* @param mixed $pk An optional primary key value check the row for. If not
* set the instance property value is used.
* @param array $joins An optional array to compiles standard joins formatted like:
* [label => 'Label', name => 'table name' , idfield => 'field', joinfield => 'field']
*
* @return boolean True on success.
*
* @deprecated 12.1
* @link http://docs.joomla.org/JTable/canDelete
* @since 11.1
*/
public function canDelete($pk = null, $joins = null)
{
// Deprecation warning.
JLog::add('JTable::canDelete() is deprecated.', JLog::WARNING, 'deprecated');
// Initialise variables.
$k = $this->_tbl_key;
$pk = is_null($pk) ? $this->{$k} : $pk;
// If no primary key is given, return false.
if ($pk === null) {
return false;
}
if (is_array($joins)) {
// Get a query object.
$query = $this->_db->getQuery(true);
// Setup the basic query.
$query->select($this->_db->quoteName($this->_tbl_key));
$query->from($this->_db->quoteName($this->_tbl));
$query->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->{$k}));
$query->group($this->_db->quoteName($this->_tbl_key));
// For each join add the select and join clauses to the query object.
foreach ($joins as $table) {
$query->select('COUNT(DISTINCT ' . $table['idfield'] . ') AS ' . $table['idfield']);
$query->join('LEFT', $table['name'] . ' ON ' . $table['joinfield'] . ' = ' . $k);
}
// Get the row object from the query.
$this->_db->setQuery((string) $query, 0, 1);
$row = $this->_db->loadObject();
// Check for a database error.
if ($this->_db->getErrorNum()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
$msg = array();
$i = 0;
foreach ($joins as $table) {
$k = $table['idfield'] . $i;
if ($row->{$k}) {
$msg[] = JText::_($table['label']);
}
$i++;
}
if (count($msg)) {
$this->setError("noDeleteRecord" . ": " . implode(', ', $msg));
return false;
} else {
return true;
}
}
return true;
}
示例2: 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;
}
示例3: _modTopicList
protected function _modTopicList($data)
{
$result = array();
$catid = intval($data);
$user = KunenaFactory::getuser();
if ($catid && $user->isModerator($catid)) {
$query = "SELECT id, subject\n\t\t\t\t\t\t\tFROM #__kunena_messages\n\t\t\t\t\t\t\tWHERE catid={$this->_db->Quote($catid)} AND parent=0 AND moved=0\n\t\t\t\t\t\t\tORDER BY id DESC";
$this->_db->setQuery($query, 0, 15);
$topics_list = $this->_db->loadObjectlist();
if ($this->_db->getErrorNum()) {
$result = array('status' => '-1', 'error' => KunenaError::getDatabaseError());
} else {
$result['status'] = '1';
$result['topiclist'] = $topics_list;
}
} else {
$result['status'] = '0';
$result['error'] = 'Error';
}
return $result;
}
示例4: getErrorNum
/**
* Gets error number
*
* @deprecated 2.0 (use exceptions instead)
*
* @return int The error number for the most recent query
*/
public function getErrorNum()
{
return $this->_db->getErrorNum();
}
示例5: getRows
public function getRows($class = null)
{
// get the subset (based on limits) of records
$query = 'SELECT *' . ' FROM #__acctexp_' . $this->table . $this->getConstraints() . $this->getOrdering() . $this->getLimit();
$this->db->setQuery($query);
$rows = $this->db->loadObjectList();
if ($this->db->getErrorNum()) {
echo $this->db->stderr();
return false;
}
if ($class) {
foreach ($rows as $k => $obj) {
$rows[$k] = new $class();
$rows[$k]->load($obj->id);
}
}
return $rows;
}