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


PHP JDatabaseDriver::getNullDate方法代码示例

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


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

示例1: checkIn

 /**
  * Method to check a row in if the necessary properties/fields exist.  Checking
  * a row in will allow other users the ability to edit the row.
  *
  * @param   mixed  $pk  An optional primary key value to check out.  If not set the instance property value is used.
  *
  * @return  boolean  True on success.
  *
  * @link    https://docs.joomla.org/JTable/checkIn
  * @since   11.1
  * @throws  UnexpectedValueException
  */
 public function checkIn($pk = null)
 {
     $checkedOutField = $this->getColumnAlias('checked_out');
     $checkedOutTimeField = $this->getColumnAlias('checked_out_time');
     // If there is no checked_out or checked_out_time field, just return true.
     if (!property_exists($this, $checkedOutField) || !property_exists($this, $checkedOutTimeField)) {
         return true;
     }
     if (is_null($pk)) {
         $pk = array();
         foreach ($this->_tbl_keys as $key) {
             $pk[$this->{$key}] = $this->{$key};
         }
     } elseif (!is_array($pk)) {
         $pk = array($this->_tbl_key => $pk);
     }
     foreach ($this->_tbl_keys as $key) {
         $pk[$key] = empty($pk[$key]) ? $this->{$key} : $pk[$key];
         if ($pk[$key] === null) {
             throw new UnexpectedValueException('Null primary key not allowed.');
         }
     }
     // Check the row in by primary key.
     $query = $this->_db->getQuery(true)->update($this->_tbl)->set($this->_db->quoteName($checkedOutField) . ' = 0')->set($this->_db->quoteName($checkedOutTimeField) . ' = ' . $this->_db->quote($this->_db->getNullDate()));
     $this->appendPrimaryKeys($query, $pk);
     $this->_db->setQuery($query);
     // Check for a database error.
     $this->_db->execute();
     // Set table values in the object.
     $this->{$checkedOutField} = 0;
     $this->{$checkedOutTimeField} = '';
     return true;
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:45,代码来源:table.php

示例2: checkIn

 /**
  * Method to check a row in if the necessary properties/fields exist.  Checking
  * a row in will allow other users the ability to edit the row.
  *
  * @param   mixed  $pk  An optional primary key value to check out.  If not set the instance property value is used.
  *
  * @return  boolean  True on success.
  *
  * @link    http://docs.joomla.org/JTable/checkIn
  * @since   11.1
  */
 public function checkIn($pk = null)
 {
     // If there is no checked_out or checked_out_time field, just return true.
     if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) {
         return true;
     }
     // Initialise variables.
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     // If no primary key is given, return false.
     if ($pk === null) {
         throw new UnexpectedValueException('Null primary key not allowed.');
     }
     // Check the row in by primary key.
     $query = $this->_db->getQuery(true);
     $query->update($this->_tbl);
     $query->set($this->_db->quoteName('checked_out') . ' = 0');
     $query->set($this->_db->quoteName('checked_out_time') . ' = ' . $this->_db->quote($this->_db->getNullDate()));
     $query->where($this->_tbl_key . ' = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query);
     // Check for a database error.
     $this->_db->execute();
     // Set table values in the object.
     $this->checked_out = 0;
     $this->checked_out_time = '';
     return true;
 }
开发者ID:ranwaldo,项目名称:joomla-platform,代码行数:38,代码来源:table.php

示例3: testGetNullDate

	/**
	 * Tests the JDatabaseDriver::getNullDate method.
	 *
	 * @return  void
	 *
	 * @since   11.4
	 */
	public function testGetNullDate()
	{
		$this->assertThat(
			$this->db->getNullDate(),
			$this->equalTo('1BC')
		);
	}
开发者ID:realityking,项目名称:joomla-platform,代码行数:14,代码来源:JDatabaseDriverTest.php

示例4: checkin

 function checkin($oid = null)
 {
     $fldLockedBy = $this->getColumnAlias('locked_by');
     $fldLockedOn = $this->getColumnAlias('locked_on');
     if (!(in_array($fldLockedBy, array_keys($this->getProperties())) || in_array($fldLockedOn, array_keys($this->getProperties())))) {
         return true;
     }
     $k = $this->_tbl_key;
     if ($oid !== null) {
         $this->{$k} = $oid;
     }
     if ($this->{$k} == null) {
         return false;
     }
     $query = $this->_db->getQuery(true)->update($this->_db->qn($this->_tbl))->set(array($this->_db->qn($fldLockedBy) . ' = 0', $this->_db->qn($fldLockedOn) . ' = ' . $this->_db->q($this->_db->getNullDate())))->where($this->_db->qn($this->_tbl_key) . ' = ' . $this->_db->q($this->{$k}));
     $this->_db->setQuery((string) $query);
     $this->{$fldLockedBy} = 0;
     $this->{$fldLockedOn} = '';
     return $this->_db->execute();
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:20,代码来源:table.php

示例5: onBeforeStore

 /**
  * The event which runs before storing (saving) data to the database
  *
  * @param   boolean  $updateNulls  Should nulls be saved as nulls (true) or just skipped over (false)?
  *
  * @return  boolean  True to allow saving
  */
 protected function onBeforeStore($updateNulls)
 {
     // Do we have a "Created" set of fields?
     $created_on = $this->getColumnAlias('created_on');
     $created_by = $this->getColumnAlias('created_by');
     $modified_on = $this->getColumnAlias('modified_on');
     $modified_by = $this->getColumnAlias('modified_by');
     $locked_on = $this->getColumnAlias('locked_on');
     $locked_by = $this->getColumnAlias('locked_by');
     $title = $this->getColumnAlias('title');
     $slug = $this->getColumnAlias('slug');
     $hasCreatedOn = in_array($created_on, $this->getKnownFields());
     $hasCreatedBy = in_array($created_by, $this->getKnownFields());
     if ($hasCreatedOn && $hasCreatedBy) {
         $hasModifiedOn = in_array($modified_on, $this->getKnownFields());
         $hasModifiedBy = in_array($modified_by, $this->getKnownFields());
         $nullDate = $this->_db->getNullDate();
         if (empty($this->{$created_by}) || $this->{$created_on} == $nullDate || empty($this->{$created_on})) {
             $uid = FOFPlatform::getInstance()->getUser()->id;
             if ($uid) {
                 $this->{$created_by} = FOFPlatform::getInstance()->getUser()->id;
             }
             $date = FOFPlatform::getInstance()->getDate('now', null, false);
             $this->{$created_on} = $date->toSql();
         } elseif ($hasModifiedOn && $hasModifiedBy) {
             $uid = FOFPlatform::getInstance()->getUser()->id;
             if ($uid) {
                 $this->{$modified_by} = FOFPlatform::getInstance()->getUser()->id;
             }
             $date = FOFPlatform::getInstance()->getDate('now', null, false);
             $this->{$modified_on} = $date->toSql();
         }
     }
     // Do we have a set of title and slug fields?
     $hasTitle = in_array($title, $this->getKnownFields());
     $hasSlug = in_array($slug, $this->getKnownFields());
     if ($hasTitle && $hasSlug) {
         if (empty($this->{$slug})) {
             // Create a slug from the title
             $this->{$slug} = FOFStringUtils::toSlug($this->{$title});
         } else {
             // Filter the slug for invalid characters
             $this->{$slug} = FOFStringUtils::toSlug($this->{$slug});
         }
         // Make sure we don't have a duplicate slug on this table
         $db = $this->getDbo();
         $query = $db->getQuery(true)->select($db->qn($slug))->from($this->_tbl)->where($db->qn($slug) . ' = ' . $db->q($this->{$slug}))->where('NOT ' . $db->qn($this->_tbl_key) . ' = ' . $db->q($this->{$this->_tbl_key}));
         $db->setQuery($query);
         $existingItems = $db->loadAssocList();
         $count = 0;
         $newSlug = $this->{$slug};
         while (!empty($existingItems)) {
             $count++;
             $newSlug = $this->{$slug} . '-' . $count;
             $query = $db->getQuery(true)->select($db->qn($slug))->from($this->_tbl)->where($db->qn($slug) . ' = ' . $db->q($newSlug))->where('NOT ' . $db->qn($this->_tbl_key) . ' = ' . $db->q($this->{$this->_tbl_key}));
             $db->setQuery($query);
             $existingItems = $db->loadAssocList();
         }
         $this->{$slug} = $newSlug;
     }
     // Call the behaviors
     $result = $this->tableDispatcher->trigger('onBeforeStore', array(&$this, $updateNulls));
     if (in_array(false, $result, true)) {
         // Behavior failed, return false
         return false;
     }
     // Execute onBeforeStore<tablename> events in loaded plugins
     if ($this->_trigger_events) {
         $name = FOFInflector::pluralize($this->getKeyName());
         $result = FOFPlatform::getInstance()->runPlugins('onBeforeStore' . ucfirst($name), array(&$this, $updateNulls));
         if (in_array(false, $result, true)) {
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:85,代码来源:table.php

示例6: __construct

 /**
  * Constructor
  *
  * @param   JDatabaseDriver  $db  Database connector object
  *
  * @since   1.5
  */
 public function __construct(JDatabaseDriver $db)
 {
     $this->typeAlias = 'com_banners.client';
     $this->checked_out_time = $db->getNullDate();
     parent::__construct('#__banner_clients', 'id', $db);
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:13,代码来源:client.php

示例7: getNullDate

 /**
  * Returns the zero date/time
  *
  * @param  string  $dateTime  'datetime', 'date', 'time'
  * @return string             Unquoted null/zero date string
  */
 public function getNullDate($dateTime = 'datetime')
 {
     return $this->formatDateOrTime($this->_db->getNullDate(), $dateTime);
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:10,代码来源:CmsDatabaseDriver.php


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