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


PHP JDatabase::getNullDate方法代码示例

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


在下文中一共展示了JDatabase::getNullDate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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    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) {
         $e = new JException(JText::_('JLIB_DATABASE_ERROR_NULL_PRIMARY_KEY'));
         $this->setError($e);
         return false;
     }
     // 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.
     if (!$this->_db->execute()) {
         $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_CHECKIN_FAILED', get_class($this), $this->_db->getErrorMsg()));
         $this->setError($e);
         return false;
     }
     // Set table values in the object.
     $this->checked_out = 0;
     $this->checked_out_time = '';
     return true;
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:44,代码来源:table.php

示例2: testGetNullDate

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

示例3: nullDate

 /**
  * Get the null or zero representation of a timestamp for the database driver.
  * @param   boolean $quoted Optionally wraps the null date in database quotes (true by default).
  * @return  string  Null or zero representation of a timestamp.
  */
 public function nullDate($quoted = true)
 {
     $result = $this->db->getNullDate($quoted);
     if ($quoted) {
         return $this->db->quote($result);
     }
     return $result;
 }
开发者ID:alexmixaylov,项目名称:real,代码行数:13,代码来源:JBDatabaseQuery.php

示例4: checkin

 /**
  * Checks in a row
  *
  * @access	public
  * @param	mixed	The primary key value for the row
  * @return	boolean	True if successful, or if checkout is not supported
  */
 function checkin($oid = null)
 {
     if (!(in_array('checked_out', array_keys($this->getProperties())) || in_array('checked_out_time', array_keys($this->getProperties())))) {
         return true;
     }
     $k = $this->_tbl_key;
     if ($oid !== null) {
         $this->{$k} = $oid;
     }
     if ($this->{$k} == NULL) {
         return false;
     }
     $query = 'UPDATE ' . $this->_db->nameQuote($this->_tbl) . ' SET checked_out = 0, checked_out_time = ' . $this->_db->Quote($this->_db->getNullDate()) . ' WHERE ' . $this->_tbl_key . ' = ' . $this->_db->Quote($this->{$k});
     $this->_db->setQuery($query);
     $this->checked_out = 0;
     $this->checked_out_time = '';
     return $this->_db->query();
 }
开发者ID:hrishikesh-kumar,项目名称:NBSNIP,代码行数:25,代码来源:table.php

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

示例6: save_resources

    function save_resources()
    {
        $db =& JFactory::getDBO();
        $cid = JRequest::getVar('cid');
        $times_access = JRequest::getInt('times_access', -1);
        $nowdate = JFactory::getDate();
        $str_now = JHTML::_('date', $nowdate->toMySQL(), '%Y-%m-%d %H:%M:%S');
        $str_nulldate = JDatabase::getNullDate();
        $start_date = JRequest::getVar('start_date', $str_now);
        $end_date = JRequest::getVar('end_date', $str_nulldate);
        $keep_original = JRequest::getInt('keep_original', 1);
        /*if (!is_array($cid)) {
        			return 0;
        		}*/
        //overwrite original
        if ($keep_original == 0) {
            //remove all current user's resources
            $query = "DELETE FROM `#__yos_resources_manager_user_resource_xref` \n\t\t\t\tWHERE `user_id` = " . $this->user->id;
            $db->setQuery($query);
            if (!$db->query()) {
                JError::raiseError(500, $db->getErrorMsg());
            }
            foreach ($cid as $res_id) {
                $query = "INSERT INTO `#__yos_resources_manager_user_resource_xref` SET \n\t\t\t\t\t`user_id` = " . $this->user->id . ', 
					`resource_id` = ' . intval($res_id) . ", \n\t\t\t\t\t`times_access` = {$times_access},\n\t\t\t\t\t`start` = '{$start_date}', \n\t\t\t\t\t`end` = '{$end_date}'";
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->getErrorMsg());
                }
            }
            return 1;
        }
        //keep original
        //select all resource
        $query = "SELECT `id` FROM `#__yos_resources_manager_resource`";
        $db->setQuery($query);
        $arr_res = $db->loadResultArray();
        if (!count($arr_res)) {
            return 0;
        }
        foreach ($arr_res as $res_id) {
            if (!in_array($res_id, $cid)) {
                //remove this resource from user
                $query = "DELETE FROM `#__yos_resources_manager_user_resource_xref` \n\t\t\t\t\tWHERE `user_id` = " . $this->user->id . " AND `resource_id` = {$res_id}";
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->getErrorMsg());
                }
            } else {
                //check is existing in database
                $query = "SELECT COUNT(id) FROM `#__yos_resources_manager_user_resource_xref`\n\t\t\t\t\tWHERE `user_id` = " . $this->user->id . " AND resource_id = {$res_id}";
                $db->setQuery($query);
                if (!$db->loadResult()) {
                    $query = "INSERT INTO `#__yos_resources_manager_user_resource_xref` SET \n\t\t\t\t\t\t`user_id` = " . $this->user->id . ', 
						`resource_id` = ' . intval($res_id) . ", \n\t\t\t\t\t\t`times_access` = {$times_access},\n\t\t\t\t\t\t`start` = '{$start_date}', \n\t\t\t\t\t\t`end` = '{$end_date}'";
                    $db->setQuery($query);
                    if (!$db->query()) {
                        JError::raiseError(500, $db->getErrorMsg());
                    }
                }
            }
        }
        return 1;
    }
开发者ID:laiello,项目名称:yrm,代码行数:64,代码来源:user.php


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