当前位置: 首页>>代码示例>>PHP>>正文


PHP JDatabase::loadObject方法代码示例

本文整理汇总了PHP中JDatabase::loadObject方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabase::loadObject方法的具体用法?PHP JDatabase::loadObject怎么用?PHP JDatabase::loadObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JDatabase的用法示例。


在下文中一共展示了JDatabase::loadObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNewItemid

 public function getNewItemid($id)
 {
     $query = 'SELECT k2_item_id,new_item_id,item_type from #__k2_recipe_map where k2_item_id =  ' . $id . ';';
     $query_set = $this->dbo->setQuery($query);
     $newitem = $this->dbo->loadObject();
     return $newitem;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:7,代码来源:find_hfrefs.php

示例2: doLoad

 /**
  * Method to load an object by primary id.
  *
  * @return  void
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 protected function doLoad()
 {
     // Get the primary key.
     $primaryKey = $this->getTableKey('primary', 'primary');
     $primaryTable = $this->getTableExpression('primary');
     // Build the query object.
     $query = $this->db->getQuery(true);
     $query->select($this->getTableKeyExpression('primary', '*'));
     $query->from($primaryTable);
     $query->where($this->getTableKeyExpression('primary', 'primary') . ' = ' . (int) $this->{$primaryKey});
     // Get the subtables.
     $tables = $this->tables;
     unset($tables['primary']);
     // Add additional tables to the query.
     foreach ($tables as $alias => $table) {
         // Add the table select and join clauses.
         $query->select($this->getTableKeyExpression($alias, '*'));
         $query->join('INNER', $this->getTableExpression($alias));
     }
     // Get the content data.
     $this->db->setQuery($query);
     $data = $this->db->loadObject();
     // Check the type data.
     if (empty($data)) {
         throw new RuntimeException(JText::sprintf('JDATABASEOBJECT_NOT_FOUND', $this->{$primaryKey}, $primaryTable));
     }
     // Bind the data.
     $this->bind($data);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:37,代码来源:object.php

示例3: 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;
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:66,代码来源:table.php

示例4: move

 /**
  * Description
  *
  * @access public
  * @param $dirn
  * @param $where
  */
 function move($dirn, $where = '')
 {
     if (!in_array('ordering', array_keys($this->getProperties()))) {
         $this->setError(get_class($this) . ' does not support ordering');
         return false;
     }
     $k = $this->_tbl_key;
     $sql = "SELECT {$this->_tbl_key}, ordering FROM {$this->_tbl}";
     if ($dirn < 0) {
         $sql .= ' WHERE ordering < ' . (int) $this->ordering;
         $sql .= $where ? ' AND ' . $where : '';
         $sql .= ' ORDER BY ordering DESC';
     } else {
         if ($dirn > 0) {
             $sql .= ' WHERE ordering > ' . (int) $this->ordering;
             $sql .= $where ? ' AND ' . $where : '';
             $sql .= ' ORDER BY ordering';
         } else {
             $sql .= ' WHERE ordering = ' . (int) $this->ordering;
             $sql .= $where ? ' AND ' . $where : '';
             $sql .= ' ORDER BY ordering';
         }
     }
     $this->_db->setQuery($sql, 0, 1);
     $row = null;
     $row = $this->_db->loadObject();
     if (isset($row)) {
         $query = 'UPDATE ' . $this->_tbl . ' SET ordering = ' . (int) $row->ordering . ' WHERE ' . $this->_tbl_key . ' = ' . $this->_db->Quote($this->{$k});
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $err = $this->_db->getErrorMsg();
             JError::raiseError(500, $err);
         }
         $query = 'UPDATE ' . $this->_tbl . ' SET ordering = ' . (int) $this->ordering . ' WHERE ' . $this->_tbl_key . ' = ' . $this->_db->Quote($row->{$k});
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $err = $this->_db->getErrorMsg();
             JError::raiseError(500, $err);
         }
         $this->ordering = $row->ordering;
     } else {
         $query = 'UPDATE ' . $this->_tbl . ' SET ordering = ' . (int) $this->ordering . ' WHERE ' . $this->_tbl_key . ' = ' . $this->_db->Quote($this->{$k});
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $err = $this->_db->getErrorMsg();
             JError::raiseError(500, $err);
         }
     }
     return true;
 }
开发者ID:Jonathonbyrd,项目名称:Joomla-Listings,代码行数:57,代码来源:table.php

示例5: _removeAttachment

 protected function _removeAttachment($data)
 {
     $result = array();
     // only registered users when the board is online will endup here
     // $data has already been escaped as part of this class
     // TODO: Get attachment details
     $query = "SELECT a.*, m.*\n\t\t\tFROM #__kunena_attachments AS a\n\t\t\tJOIN #__kunena_messages AS m ON a.mesid = m.id\n\t\t\tWHERE a.id = '" . $data . "'";
     $this->_db->setQuery($query);
     $attachment = $this->_db->loadObject();
     if ($this->_db->getErrorNum()) {
         $result = array('status' => '-1', 'error' => KunenaError::getDatabaseError());
         return $result;
     }
     // Verify permissions, user must be author of the message this
     // attachment is attached to or be a moderator or admin of the site
     if ($attachment->userid != $this->_my->id && !CKunenaTools::isModerator($this->_my->id, $attachment->catid) && !CKunenaTools::isAdmin()) {
         // not the author, not a moderator, not an admin
         // nothing todo here - end with permission error
         $result = array('status' => '-1', 'error' => JText::_('COM_KUNENA_AJAX_PERMISSION_DENIED'));
         return $result;
     }
     // Request coming form valid user, moderator or admin...
     // First remove files from filsystem - check for thumbs and raw in case this is an image
     if (file_exists(JPATH_ROOT . $attachment->folder . $attachment->filename)) {
         JFile::delete(JPATH_ROOT . $attachment->folder . $attachment->filename);
     }
     if (file_exists(JPATH_ROOT . $attachment->folder . '/raw/' . $attachment->filename)) {
         JFile::delete(JPATH_ROOT . $attachment->folder . '/raw/' . $attachment->filename);
     }
     if (file_exists(JPATH_ROOT . $attachment->folder . '/thumb/' . $attachment->filename)) {
         JFile::delete(JPATH_ROOT . $attachment->folder . '/thumb/' . $attachment->filename);
     }
     // Finally delete attachment record from db
     $query = "DELETE FROM #__kunena_attachments AS a\n\t\t\t\t\tWHERE a.id = {$this->_db->Quote($data)}";
     $this->_db->setQuery($query);
     $this->_db->query();
     if ($this->_db->getErrorNum()) {
         $result = array('status' => '-1', 'error' => KunenaError::getDatabaseError());
     } else {
         $result = array('status' => '1', 'error' => JText::_('COM_KUNENA_AJAX_ATTACHMENT_DELETED'));
     }
     return $result;
 }
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:43,代码来源:kunena.ajax.helper.php

示例6: loadObject

 /**
  * This global function loads the first row of a query into an object
  *
  * If an object is passed to this function, the returned row is bound to the existing elements of <var>object</var>.
  * If <var>object</var> has a value of null, then all of the returned query fields returned in the object.
  * @param  object|\stdClass  $object
  * @return boolean          Success
  *
  * @throws  \RuntimeException
  */
 public function loadObject(&$object)
 {
     if ($object === null) {
         $object = $this->_db->loadObject();
         return is_object($object);
     }
     $array = $this->_db->loadAssoc();
     if (!is_array($array)) {
         return false;
     }
     foreach (get_object_vars($object) as $k => $v) {
         if (substr($k, 0, 1) != '_') {
             if (array_key_exists($k, $array)) {
                 $object->{$k} = $array[$k];
             }
         }
     }
     return true;
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:29,代码来源:CmsDatabaseDriver.php

示例7: canDelete

 /**
  * Generic check for whether dependancies exist for this object in the db schema
  *
  * can be overloaded/supplemented by the child class
  *
  * @access public
  * @param string $msg Error message returned
  * @param int Optional key index
  * @param array Optional array to compiles standard joins: format [label=>'Label',name=>'table name',idfield=>'field',joinfield=>'field']
  * @return true|false
  */
 function canDelete($oid = null, $joins = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (is_array($joins)) {
         $select = "{$k}";
         $join = "";
         foreach ($joins as $table) {
             $select .= ', COUNT(DISTINCT ' . $table['idfield'] . ') AS ' . $table['idfield'];
             $join .= ' LEFT JOIN ' . $table['name'] . ' ON ' . $table['joinfield'] . ' = ' . $k;
         }
         $query = 'SELECT ' . $select . ' FROM ' . $this->_tbl . $join . ' WHERE ' . $k . ' = ' . $this->_db->Quote($this->{$k}) . ' GROUP BY ' . $k;
         $this->_db->setQuery($query);
         if (!($obj = $this->_db->loadObject())) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $msg = array();
         $i = 0;
         foreach ($joins as $table) {
             $k = $table['idfield'] . $i;
             if ($obj->{$k}) {
                 $msg[] = JText::_($table['label']);
             }
             $i++;
         }
         if (count($msg)) {
             $this->setError("noDeleteRecord" . ": " . implode(', ', $msg));
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
开发者ID:hrishikesh-kumar,项目名称:NBSNIP,代码行数:48,代码来源:table.php

示例8: queryObject

 /**
  * Execute a query to the database and load the result returned as an object
  *
  * The result returned by this method is the same as the one returned by JDatabase::loadObject()
  * Basically, it returns the first result of a database operation as an object
  * Generally used for SELECT fields operations
  *
  * @param string $query The query to be executed
  *
  * @return object The result of the query
  *
  * @throws RuntimeException
  *
  * @since 1.0.0
  */
 public function queryObject($query)
 {
     // query database table
     $this->_database->setQuery($query);
     return $this->_database->loadObject();
 }
开发者ID:JBZoo,项目名称:Zoo-Changelog,代码行数:21,代码来源:database.php


注:本文中的JDatabase::loadObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。