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


PHP JDatabaseDriver::getErrorMsg方法代码示例

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


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

示例1: store

	public function store($updateNulls = false)
	{
		if ($this->exists())
		{
			$ret = static::$db->updateObject(static::$tbl, $this, static::$tbl_keys, $updateNulls);
		}
		else
		{
			$ret = static::$db->insertObject(static::$tbl, $this, static::$tbl_keys);
		}

		if (static::$locked)
		{
			$this->unlock();
		}

		if (!$ret)
		{
			$this->setError(get_class($this) . '::store failed - ' . static::$db->getErrorMsg());

			return false;
		}

		$this->_exists = true;

		return true;
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:27,代码来源:object.php

示例2: publish

 /**
  * Publish or unpublish records
  *
  * @param   integer|array  $cid      The primary key value(s) of the item(s) to publish/unpublish
  * @param   integer        $publish  1 to publish an item, 0 to unpublish
  * @param   integer        $user_id  The user ID of the user (un)publishing the item.
  *
  * @return  boolean  True on success, false on failure (e.g. record is locked)
  */
 public function publish($cid = null, $publish = 1, $user_id = 0)
 {
     $enabledName = $this->getColumnAlias('enabled');
     $locked_byName = $this->getColumnAlias('locked_by');
     // Mhm... you called the publish method on a table without publish support...
     if (!in_array($enabledName, $this->getKnownFields())) {
         return false;
     }
     //We have to cast the id as array, or the helper function will return an empty set
     if ($cid) {
         $cid = (array) $cid;
     }
     FOFUtilsArray::toInteger($cid);
     $user_id = (int) $user_id;
     $publish = (int) $publish;
     $k = $this->_tbl_key;
     if (count($cid) < 1) {
         if ($this->{$k}) {
             $cid = array($this->{$k});
         } else {
             $this->setError("No items selected.");
             return false;
         }
     }
     if (!$this->onBeforePublish($cid, $publish)) {
         return false;
     }
     $query = $this->_db->getQuery(true)->update($this->_db->qn($this->_tbl))->set($this->_db->qn($enabledName) . ' = ' . (int) $publish);
     $checkin = in_array($locked_byName, $this->getKnownFields());
     if ($checkin) {
         $query->where(' (' . $this->_db->qn($locked_byName) . ' = 0 OR ' . $this->_db->qn($locked_byName) . ' = ' . (int) $user_id . ')', 'AND');
     }
     // TODO Rewrite this statment using IN. Check if it work in SQLServer and PostgreSQL
     $cids = $this->_db->qn($k) . ' = ' . implode(' OR ' . $this->_db->qn($k) . ' = ', $cid);
     $query->where('(' . $cids . ')');
     $this->_db->setQuery((string) $query);
     if (version_compare(JVERSION, '3.0', 'ge')) {
         try {
             $this->_db->execute();
         } catch (JDatabaseException $e) {
             $this->setError($e->getMessage());
         }
     } else {
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     if (count($cid) == 1 && $checkin) {
         if ($this->_db->getAffectedRows() == 1) {
             $this->checkin($cid[0]);
             if ($this->{$k} == $cid[0]) {
                 $this->{$enabledName} = $publish;
             }
         }
     }
     $this->setError('');
     return true;
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:68,代码来源:table.php

示例3: publish

 function publish($cid = null, $publish = 1, $user_id = 0)
 {
     JArrayHelper::toInteger($cid);
     $user_id = (int) $user_id;
     $publish = (int) $publish;
     $k = $this->_tbl_key;
     if (count($cid) < 1) {
         if ($this->{$k}) {
             $cid = array($this->{$k});
         } else {
             $this->setError("No items selected.");
             return false;
         }
     }
     if (!$this->onBeforePublish($cid, $publish)) {
         return false;
     }
     $enabledName = $this->getColumnAlias('enabled');
     $locked_byName = $this->getColumnAlias('locked_by');
     $query = $this->_db->getQuery(true)->update($this->_db->qn($this->_tbl))->set($this->_db->qn($enabledName) . ' = ' . (int) $publish);
     $checkin = in_array($locked_byName, array_keys($this->getProperties()));
     if ($checkin) {
         $query->where(' (' . $this->_db->qn($locked_byName) . ' = 0 OR ' . $this->_db->qn($locked_byName) . ' = ' . (int) $user_id . ')', 'AND');
     }
     $cids = $this->_db->qn($k) . ' = ' . implode(' OR ' . $this->_db->qn($k) . ' = ', $cid);
     $query->where('(' . $cids . ')');
     $this->_db->setQuery((string) $query);
     if (version_compare(JVERSION, '3.0', 'ge')) {
         try {
             $this->_db->execute();
         } catch (JDatabaseException $e) {
             $this->setError($e->getMessage());
         }
     } else {
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     if (count($cid) == 1 && $checkin) {
         if ($this->_db->getAffectedRows() == 1) {
             $this->checkin($cid[0]);
             if ($this->{$k} == $cid[0]) {
                 $this->published = $publish;
             }
         }
     }
     $this->setError('');
     return true;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:50,代码来源:table.php

示例4: populateDatabase

 /**
  * Method to import a database schema from a file.
  *
  * @param   JDatabaseDriver  $db      JDatabase object.
  * @param   string           $schema  Path to the schema file.
  *
  * @return  boolean  True on success.
  *
  * @since   3.1
  */
 public function populateDatabase($db, $schema)
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = JFactory::getApplication();
     $return = true;
     // Get the contents of the schema file.
     if (!($buffer = file_get_contents($schema))) {
         $app->enqueueMessage($db->getErrorMsg(), 'notice');
         return false;
     }
     // Get an array of queries from the schema and process them.
     $queries = $this->_splitQueries($buffer);
     foreach ($queries as $query) {
         // Trim any whitespace.
         $query = trim($query);
         // If the query isn't empty and is not a MySQL or PostgreSQL comment, execute it.
         if (!empty($query) && $query[0] != '#' && $query[0] != '-') {
             /**
              * If we don't have UTF-8 Multibyte support we'll have to convert queries to plain UTF-8
              *
              * Note: the JDatabaseDriver::convertUtf8mb4QueryToUtf8 performs the conversion ONLY when
              * necessary, so there's no need to check the conditions in JInstaller.
              */
             $query = $db->convertUtf8mb4QueryToUtf8($query);
             /**
              * This is a query which was supposed to convert tables to utf8mb4 charset but the server doesn't
              * support utf8mb4. Therefore we don't have to run it, it has no effect and it's a mere waste of time.
              */
             if (!$db->hasUTF8mb4Support() && stristr($query, 'CONVERT TO CHARACTER SET utf8 ')) {
                 continue;
             }
             // Execute the query.
             $db->setQuery($query);
             try {
                 $db->execute();
             } catch (RuntimeException $e) {
                 $app->enqueueMessage($e->getMessage(), 'notice');
                 $return = false;
             }
         }
     }
     return $return;
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:54,代码来源:database.php

示例5: populateDatabase

 /**
  * Method to import a database schema from a file.
  *
  * @param   JDatabaseDriver  $db      JDatabase object.
  * @param   string           $schema  Path to the schema file.
  *
  * @return  boolean  True on success.
  *
  * @since   3.1
  */
 public function populateDatabase($db, $schema)
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = JFactory::getApplication();
     $return = true;
     // Get the contents of the schema file.
     if (!($buffer = file_get_contents($schema))) {
         $app->enqueueMessage($db->getErrorMsg(), 'notice');
         return false;
     }
     // Get an array of queries from the schema and process them.
     $queries = $this->_splitQueries($buffer);
     foreach ($queries as $query) {
         // Trim any whitespace.
         $query = trim($query);
         // If the query isn't empty and is not a MySQL or PostgreSQL comment, execute it.
         if (!empty($query) && $query[0] != '#' && $query[0] != '-') {
             // Execute the query.
             $db->setQuery($query);
             try {
                 $db->execute();
             } catch (RuntimeException $e) {
                 $app->enqueueMessage($e->getMessage(), 'notice');
                 $return = false;
             }
         }
     }
     return $return;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:40,代码来源:database.php

示例6: getErrorMsg

 /**
  * Gets error message
  *
  * @deprecated 2.0 (use exceptions instead)
  *
  * @return string The error message for the most recent query
  */
 public function getErrorMsg()
 {
     return stripslashes($this->_db->getErrorMsg());
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:11,代码来源:CmsDatabaseDriver.php

示例7: populateDatabase

 /**
  * Method to import a database schema from a file.
  *
  * @param   JDatabaseDriver  $db      JDatabase object.
  * @param   string           $schema  Path to the schema file.
  *
  * @return	boolean	True on success.
  *
  * @since	3.0
  */
 public function populateDatabase($db, $schema)
 {
     // Initialise variables.
     $return = true;
     // Get the contents of the schema file.
     if (!($buffer = file_get_contents($schema))) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     // Get an array of queries from the schema and process them.
     $queries = $this->_splitQueries($buffer);
     foreach ($queries as $query) {
         // Trim any whitespace.
         $query = trim($query);
         // If the query isn't empty and is not a comment, execute it.
         if (!empty($query) && $query[0] != '#') {
             // Execute the query.
             $db->setQuery($query);
             try {
                 $db->execute();
             } catch (RuntimeException $e) {
                 $this->setError($e->getMessage());
                 $return = false;
             }
         }
     }
     return $return;
 }
开发者ID:exntu,项目名称:joomla-cms,代码行数:38,代码来源:database.php


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