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


PHP JDatabaseDriver::loadObject方法代码示例

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


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

示例1: remove

 /**
  * Remove an extra image from database and file system.
  *
  * <code>
  * $imageId = 1;
  * $imagesFolder = "/.../folder";
  *
  * $image   = new CrowdFundingImageRemoverExtra(JFactory::getDbo(), $image, $imagesFolder);
  * $image->remove();
  * </code>
  */
 public function remove()
 {
     // Get the image
     $query = $this->db->getQuery(true);
     $query->select("a.image, a.thumb")->from($this->db->quoteName("#__crowdf_images", "a"))->where("a.id = " . (int) $this->imageId);
     $this->db->setQuery($query);
     $row = $this->db->loadObject();
     if (!empty($row)) {
         // Remove the image from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->image);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Remove the thumbnail from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->thumb);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Delete the record
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName("#__crowdf_images"))->where($this->db->quoteName("id") . " = " . (int) $this->imageId);
         $this->db->setQuery($query);
         $this->db->execute();
     }
 }
开发者ID:phpsource,项目名称:CrowdFunding,代码行数:36,代码来源:extra.php

示例2: getType

 /**
  * Get the Content Type
  *
  * @param   integer  $pk  The primary key of the alias type
  *
  * @return  object  The UCM Type data
  *
  * @since   3.1
  */
 public function getType($pk = null)
 {
     if (!$pk) {
         $pk = $this->getTypeId();
     }
     $query = $this->db->getQuery(true);
     $query->select('ct.*');
     $query->from($this->db->quoteName('#__content_types', 'ct'));
     $query->where($this->db->quoteName('ct.type_id') . ' = ' . (int) $pk);
     $this->db->setQuery($query);
     $type = $this->db->loadObject();
     return $type;
 }
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:22,代码来源:type.php

示例3: getFundedAmount

 /**
  * Calculate three types of project amount - goal, funded amount and remaining amount.
  *
  * <code>
  * $projectId    = 1;
  *
  * $statistics   = new CrowdfundingStatisticsProject(\JFactory::getDbo(), $projectId);
  * $data = $statistics->getFundedAmount();
  * </code>
  *
  * @return array
  *
  * # Example result:
  * array(
  *    "goal" = array("label" => "Goal", "amount" => 1000),
  *    "funded" = array("label" => "Funded", "amount" => 100),
  *    "remaining" = array("label" => "Remaining", "amount" => 900)
  * )
  */
 public function getFundedAmount()
 {
     $data = array();
     $query = $this->db->getQuery(true);
     $query->select("a.funded, a.goal")->from($this->db->quoteName("#__crowdf_projects", "a"))->where("a.id = " . (int) $this->id);
     $this->db->setQuery($query);
     $result = $this->db->loadObject();
     /** @var $result object */
     if (empty($result->funded) or empty($result->goal)) {
         return $data;
     }
     // Get currency
     $params = \JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Registry */
     $currencyId = $params->get("project_currency");
     $currency = Currency::getInstance(\JFactory::getDbo(), $currencyId, $params);
     $amount = new Amount();
     $amount->setCurrency($currency);
     $data["goal"] = array("label" => \JText::sprintf("COM_CROWDFUNDINGFINANCE_GOAL_S", $amount->setValue($result->goal)->formatCurrency()), "amount" => (double) $result->goal);
     $data["funded"] = array("label" => \JText::sprintf("COM_CROWDFUNDINGFINANCE_FUNDED_S", $amount->setValue($result->funded)->formatCurrency()), "amount" => (double) $result->funded);
     $remaining = (double) ($result->goal - $result->funded);
     if ($remaining < 0) {
         $remaining = 0;
     }
     $data["remaining"] = array("label" => \JText::sprintf("COM_CROWDFUNDINGFINANCE_REMAINING_S", $amount->setValue($remaining)->formatCurrency()), "amount" => $remaining);
     return $data;
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:46,代码来源:Project.php

示例4: move

 /**
  * Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
  * Negative numbers move the row up in the sequence and positive numbers move it down.
  *
  * @param integer $delta The direction and magnitude to move the row in the ordering sequence.
  * @param string  $where WHERE clause to use for limiting the selection of rows to compact the
  *                           ordering values.
  *
  * @return mixed Boolean  True on success.
  *
  * @link    http://docs.joomla.org/JTable/move
  * @since   11.1
  * @throws UnexpectedValueException
  */
 public function move($delta, $where = '')
 {
     // If there is no ordering field set an error and return false.
     if (!property_exists($this, 'ordering')) {
         throw new UnexpectedValueException(sprintf('%s does not support ordering.', get_class($this)));
     }
     // If the change is none, do nothing.
     if (empty($delta)) {
         return true;
     }
     $k = $this->_tbl_key;
     $row = null;
     $query = $this->_db->getQuery(true);
     // Select the primary key and ordering values from the table.
     $query->select($this->_tbl_key . ', ordering');
     $query->from($this->_tbl);
     // If the movement delta is negative move the row up.
     if ($delta < 0) {
         $query->where('ordering < ' . (int) $this->ordering);
         $query->order('ordering DESC');
     } elseif ($delta > 0) {
         $query->where('ordering > ' . (int) $this->ordering);
         $query->order('ordering ASC');
     }
     // Add the custom WHERE clause if set.
     if ($where) {
         $query->where($where);
     }
     // Select the first row with the criteria.
     $this->_db->setQuery($query, 0, 1);
     $row = $this->_db->loadObject();
     // If a row is found, move the item.
     if (!empty($row)) {
         // Update the ordering field for this instance to the row's ordering value.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('ordering = ' . (int) $row->ordering);
         $query->where($this->_tbl_key . ' = ' . $this->_db->quote($this->{$k}));
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Update the ordering field for the row to this instance's ordering value.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('ordering = ' . (int) $this->ordering);
         $query->where($this->_tbl_key . ' = ' . $this->_db->quote($row->{$k}));
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Update the instance value.
         $this->ordering = $row->ordering;
     } else {
         // Update the ordering field for this instance.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('ordering = ' . (int) $this->ordering);
         $query->where($this->_tbl_key . ' = ' . $this->_db->quote($this->{$k}));
         $this->_db->setQuery($query);
         $this->_db->execute();
     }
     return true;
 }
开发者ID:houzhenggang,项目名称:cobalt,代码行数:74,代码来源:table.php

示例5: loadArticle

 /**
  * Function to retrieve the full article object
  *
  * @param   object  $article  The content object
  *
  * @return  object  The full content object
  *
  * @since   1.0
  */
 private function loadArticle($article)
 {
     // Query the database for the article text
     $query = $this->db->getQuery(true)->select('*')->from($this->db->quoteName('#__content'))->where($this->db->quoteName('introtext') . ' = ' . $this->db->quote($article->text));
     $this->db->setQuery($query);
     return $this->db->loadObject();
 }
开发者ID:joomla-projects,项目名称:plg_content_joomlarrssb,代码行数:16,代码来源:joomlarrssb.php

示例6: getAmounts

 /**
  * Count and return transactions number.
  *
  * <code>
  * $usersId = 1;
  *
  * $statistics         = new CrowdFundingStatisticsUsers(JFactory::getDbo(), $usersId);
  * $transactionsNumber = $statistics->getAmounts();
  * </code>
  *
  * @return array
  */
 public function getAmounts()
 {
     // If there are no IDs, return empty array.
     if (!$this->id) {
         return array();
     }
     $statistics = array("invested" => array(), "received" => array());
     // Count invested amount and transactions.
     $query = $this->db->getQuery(true);
     $query->select("COUNT(*) AS number, SUM(a.txn_amount) AS amount")->from($this->db->quoteName("#__crowdf_transactions", "a"))->where("a.investor_id = " . (int) $this->id);
     $this->db->setQuery($query);
     $results = $this->db->loadObject();
     if (!$results) {
         $results = array();
     }
     $statistics["invested"] = $results;
     // Count received amount and transactions.
     $query = $this->db->getQuery(true);
     $query->select("COUNT(*) AS number, SUM(a.txn_amount) AS amount")->from($this->db->quoteName("#__crowdf_transactions", "a"))->where("a.receiver_id = " . (int) $this->id);
     $this->db->setQuery($query);
     $results = $this->db->loadObject();
     if (!$results) {
         $results = array();
     }
     $statistics["received"] = $results;
     return $statistics;
 }
开发者ID:phpsource,项目名称:CrowdFunding,代码行数:39,代码来源:user.php

示例7: getFundedAmount

 /**
  * Calculate three types of project amount - goal, funded amount and remaining amount.
  *
  * <code>
  * $projectId    = 1;
  *
  * $statistics   = new Crowdfunding\Statistics\Project(\JFactory::getDbo(), $projectId);
  * $data = $statistics->getFundedAmount();
  * </code>
  *
  * @return array
  *
  * # Example result:
  * array(
  *    "goal" = array("label" => "Goal", "amount" => 1000),
  *    "funded" = array("label" => "Funded", "amount" => 100),
  *    "remaining" = array("label" => "Remaining", "amount" => 900)
  * )
  */
 public function getFundedAmount()
 {
     $data = array();
     $query = $this->db->getQuery(true);
     $query->select('a.funded, a.goal')->from($this->db->quoteName('#__crowdf_projects', 'a'))->where('a.id = ' . (int) $this->id);
     $this->db->setQuery($query);
     $result = $this->db->loadObject();
     /** @var $result \stdClass */
     if ($result->funded === null or $result->goal === null) {
         return $data;
     }
     // Get currency
     $params = \JComponentHelper::getParams('com_crowdfunding');
     /** @var  $params Registry */
     $currencyId = $params->get('project_currency');
     $currency = Currency::getInstance(\JFactory::getDbo(), $currencyId, $params);
     $amount = new Amount();
     $amount->setCurrency($currency);
     $data['goal'] = array('label' => \JText::sprintf('COM_CROWDFUNDINGFINANCE_GOAL_S', $amount->setValue($result->goal)->formatCurrency()), 'amount' => (double) $result->goal);
     $data['funded'] = array('label' => \JText::sprintf('COM_CROWDFUNDINGFINANCE_FUNDED_S', $amount->setValue($result->funded)->formatCurrency()), 'amount' => (double) $result->funded);
     $remaining = (double) ($result->goal - $result->funded);
     if ($remaining < 0) {
         $remaining = 0;
     }
     $data['remaining'] = array('label' => \JText::sprintf('COM_CROWDFUNDINGFINANCE_REMAINING_S', $amount->setValue($remaining)->formatCurrency()), 'amount' => $remaining);
     return $data;
 }
开发者ID:bellodox,项目名称:CrowdFunding,代码行数:46,代码来源:Project.php

示例8: move

 /**
  * Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
  *
  * Negative numbers move the row up in the sequence and positive numbers move it down.
  *
  * @param   integer  $delta  The direction and magnitude to move the row in the ordering sequence.
  * @param   string   $where  WHERE clause to use for limiting the selection of rows to compact the ordering values.
  *
  * @return  boolean  True on success.
  *
  * @since   11.1
  * @throws  UnexpectedValueException
  */
 public function move($delta, $where = '')
 {
     // If there is no ordering field set an error and return false.
     if (!property_exists($this, 'ordering')) {
         throw new UnexpectedValueException(sprintf('%s does not support ordering.', get_class($this)));
     }
     // If the change is none, do nothing.
     if (empty($delta)) {
         return true;
     }
     $k = $this->_tbl_key;
     $row = null;
     $query = $this->_db->getQuery(true);
     // Select the primary key and ordering values from the table.
     $query->select(implode(',', $this->_tbl_keys) . ', ordering')->from($this->_tbl);
     // If the movement delta is negative move the row up.
     if ($delta < 0) {
         $query->where('ordering < ' . (int) $this->ordering)->order('ordering DESC');
     } elseif ($delta > 0) {
         $query->where('ordering > ' . (int) $this->ordering)->order('ordering ASC');
     }
     // Add the custom WHERE clause if set.
     if ($where) {
         $query->where($where);
     }
     // Pre-processing by observers
     $event = AbstractEvent::create('onTableBeforeMove', ['subject' => $this, 'query' => $query, 'delta' => $delta, 'where' => $where]);
     $this->getDispatcher()->dispatch('onTableBeforeMove', $event);
     // Select the first row with the criteria.
     $this->_db->setQuery($query, 0, 1);
     $row = $this->_db->loadObject();
     // If a row is found, move the item.
     if (!empty($row)) {
         // Update the ordering field for this instance to the row's ordering value.
         $query->clear()->update($this->_tbl)->set('ordering = ' . (int) $row->ordering);
         $this->appendPrimaryKeys($query);
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Update the ordering field for the row to this instance's ordering value.
         $query->clear()->update($this->_tbl)->set('ordering = ' . (int) $this->ordering);
         $this->appendPrimaryKeys($query, $row);
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Update the instance value.
         $this->ordering = $row->ordering;
     } else {
         // Update the ordering field for this instance.
         $query->clear()->update($this->_tbl)->set('ordering = ' . (int) $this->ordering);
         $this->appendPrimaryKeys($query);
         $this->_db->setQuery($query);
         $this->_db->execute();
     }
     // Post-processing by observers
     $event = AbstractEvent::create('onTableAfterMove', ['subject' => $this, 'row' => $row, 'delta' => $delta, 'where' => $where]);
     $this->getDispatcher()->dispatch('onTableAfterMove', $event);
     return true;
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:70,代码来源:table.php

示例9: getTypeByAlias

 /**
  * Get the Content Type from the alias
  *
  * @param   string  $typeAlias  The alias for the type
  *
  * @return  object  The UCM Type data
  *
  * @since   3.2
  */
 public function getTypeByAlias($typeAlias = null)
 {
     $query = $this->db->getQuery(true);
     $query->select('ct.*');
     $query->from($this->db->quoteName('#__content_types', 'ct'));
     $query->where($this->db->quoteName('ct.type_alias') . ' = ' . $this->db->quote($typeAlias));
     $this->db->setQuery($query);
     $type = $this->db->loadObject();
     return $type;
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:19,代码来源:type.php

示例10: getAmounts

 /**
  * Count and return transactions number.
  *
  * <code>
  * $usersId = 1;
  *
  * $statistics         = new Crowdfunding\Statistics\Users(\JFactory::getDbo(), $usersId);
  * $transactionsNumber = $statistics->getAmounts();
  * </code>
  *
  * @return array
  */
 public function getAmounts()
 {
     $statistics = array('invested' => array(), 'received' => array());
     // Count invested amount and transactions.
     $query = $this->db->getQuery(true);
     $query->select('COUNT(*) AS number, SUM(a.txn_amount) AS amount')->from($this->db->quoteName('#__crowdf_transactions', 'a'))->where('a.investor_id = ' . (int) $this->id);
     $this->db->setQuery($query);
     $statistics['invested'] = (array) $this->db->loadObject();
     // Count received amount and transactions.
     $query = $this->db->getQuery(true);
     $query->select('COUNT(*) AS number, SUM(a.txn_amount) AS amount')->from($this->db->quoteName('#__crowdf_transactions', 'a'))->where('a.receiver_id = ' . (int) $this->id);
     $this->db->setQuery($query);
     $statistics['received'] = (array) $this->db->loadObject();
     return $statistics;
 }
开发者ID:bellodox,项目名称:CrowdFunding,代码行数:27,代码来源:User.php

示例11: check

 /**
  * Runs the check query and checks that 1 row is returned
  * If yes, return true, otherwise return false
  *
  * @return  boolean  true on success, false otherwise
  *
  * @since  2.5
  */
 public function check()
 {
     $this->checkStatus = -1;
     if ($this->checkQuery) {
         $this->db->setQuery($this->checkQuery);
         $rows = $this->db->loadObject();
         if ($rows !== false) {
             if (count($rows) === $this->checkQueryExpected) {
                 $this->checkStatus = 1;
             } else {
                 $this->checkStatus = -2;
             }
         } else {
             $this->checkStatus = -2;
         }
     }
     return $this->checkStatus;
 }
开发者ID:exntu,项目名称:joomla-cms,代码行数:26,代码来源:changeitem.php

示例12: prepareBadges

 /**
  * Prepare current and next badges.
  *
  * @param array $keys
  */
 protected function prepareBadges($keys)
 {
     $this->currentUnit = Badge::getInstance($this->db, $keys);
     $userPoints = $this->points->getPoints();
     // Get all units
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.title, a.points, a.image, a.note, a.published, a.points_id, a.group_id")->from($this->db->quoteName("#__gfy_badges", "a"))->where("a.points_id = " . (int) $this->points->getPointsId())->where("a.published = 1")->where("a.points > " . (int) $userPoints);
     $this->db->setQuery($query, 0, 1);
     $result = $this->db->loadObject();
     if (!empty($result)) {
         $this->nextUnit = new \Gamification\Badge\Badge($this->db);
         $this->nextUnit->bind($result);
         $this->percentage = $this->calculatePercentage($userPoints, $this->nextUnit->getPoints());
         $this->percentNext = 100 - $this->percentage;
     } else {
         $this->percentage = 100;
         $this->percentNext = 100;
     }
 }
开发者ID:bellodox,项目名称:GamificationPlatform,代码行数:24,代码来源:Progressbar.php

示例13: 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

示例14: getFundedAmount

 /**
  * Calculate three types of project amount - goal, funded amount and remaining amount.
  *
  * <code>
  * $projectId    = 1;
  *
  * $statistics   = new CrowdFundingStatisticsProject(JFactory::getDbo(), $projectId);
  * $data = $statistics->getFundedAmount();
  * </code>
  *
  * @return array
  *
  * # Example result:
  * array(
  *    "goal" = array("label" => "Goal", "amount" => 1000),
  *    "funded" = array("label" => "Funded", "amount" => 100),
  *    "remaining" = array("label" => "Remaining", "amount" => 900)
  * )
  */
 public function getFundedAmount()
 {
     $data = array();
     $query = $this->db->getQuery(true);
     $query->select("a.funded, a.goal")->from($this->db->quoteName("#__crowdf_projects", "a"))->where("a.id = " . (int) $this->id);
     $this->db->setQuery($query);
     $result = $this->db->loadObject();
     /** @var $result object */
     if (empty($result->funded) or empty($result->goal)) {
         return $data;
     }
     $data["goal"] = array("label" => JText::_("LIB_CROWDFUNDING_GOAL"), "amount" => (double) $result->goal);
     $data["funded"] = array("label" => JText::_("LIB_CROWDFUNDING_FUNDED"), "amount" => (double) $result->funded);
     $remaining = (double) ($result->goal - $result->funded);
     if ($remaining < 0) {
         $remaining = 0;
     }
     $data["remaining"] = array("label" => JText::_("LIB_CROWDFUNDING_REMAINING"), "amount" => $remaining);
     return $data;
 }
开发者ID:phpsource,项目名称:CrowdFunding,代码行数:39,代码来源:project.php

示例15: check

 /**
  * Runs the check query and checks that 1 row is returned
  * If yes, return true, otherwise return false
  *
  * @return  boolean  true on success, false otherwise
  *
  * @since  2.5
  */
 public function check()
 {
     $this->checkStatus = -1;
     if ($this->checkQuery) {
         $this->db->setQuery($this->checkQuery);
         try {
             $rows = $this->db->loadObject();
         } catch (RuntimeException $e) {
             $rows = false;
             // Still render the error message from the Exception object
             JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
         }
         if ($rows !== false) {
             if (count($rows) === $this->checkQueryExpected) {
                 $this->checkStatus = 1;
             } else {
                 $this->checkStatus = -2;
             }
         } else {
             $this->checkStatus = -2;
         }
     }
     return $this->checkStatus;
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:32,代码来源:changeitem.php


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