fetch() 공개 메소드

Fetch a single record from the database for the given key.
public fetch ( array $p_recordSet = null, boolean $p_forceExists = false ) : boolean
$p_recordSet array If the record has already been fetched and we just need to assign the data to the object's internal member variable.
$p_forceExists boolean prevents to check for the object existence in the database, a performance thing for situations where we know it exists.
리턴 boolean TRUE on success, FALSE on failure
예제 #1
0
파일: Topic.php 프로젝트: nidzix/Newscoop
 /**
  * Fetch the topic and all its translations.
  *
  * The values array may have the following keys:
  * - id - topic identifier; if not supplied generated automatically
  * - node_left
  * - node_right
  * - names - array of topic translations of the form: language_id => name
  *
  * @return void
  */
 public function fetch($p_columns = null, $p_forceExists = false)
 {
     global $g_ado_db;
     if (!is_null($p_columns)) {
         if (!isset($p_columns['names'])) {
             return false;
         }
         if ($this->readFromCache($p_columns) !== false) {
             return true;
         }
         foreach ($p_columns as $columnName => $value) {
             if (in_array($columnName, $this->m_columnNames)) {
                 $this->m_data[$columnName] = $value;
             }
         }
         $this->m_names = $p_columns['names'];
         $this->m_exists = true;
     } else {
         if ($this->readFromCache() !== false) {
             return true;
         }
         parent::fetch();
         if ($this->exists()) {
             $this->m_names = TopicName::GetTopicNames($this->getTopicId());
         }
     }
     if ($this->m_exists) {
         // Write the object to cache
         $this->writeCache();
     }
     return $this->m_exists;
 }
예제 #2
0
	/**
	 * Fetch a single record from the database for the given key.
	 *
	 * @param array $p_arg
	 *		If the record has already been fetched and we just need to
	 * 		assign the data to the object's internal member variable.
	 *
	 * @return boolean
	 *		TRUE on success, FALSE on failure
	 */
    public function fetch($arg = null)
    {
    	global $g_ado_db;

        if (is_array($arg)) {
        	return parent::fetch($arg);
        }

        if (!$this->keyValuesExist()) {
        	return false;
        }
        if ($this->readFromCache() !== false) {
        	return true;
        }

        $queryStr = 'SELECT *, X(poi_location) as latitude, Y(poi_location) as longitude
                FROM ' . self::TABLE . '
                WHERE id = ' . $this->getId();
        $this->m_data = $g_ado_db->GetRow($queryStr);
        $this->m_exists = count($this->m_data) > 0;

        if ($this->m_exists) {
		    // Write the object to cache
		    $this->writeCache();
		}

        return $this->m_exists;
    }
예제 #3
0
    /**
     * Fetch a single record from the database for the given key.
     *
     * @param array $p_recordSet
     *      If the record has already been fetched and we just need to
     *      assign the data to the object's internal member variable.
     *
     * @return boolean
     *      TRUE on success, FALSE on failure
     */
	public function fetch($p_recordSet = null)
	{
		$res = parent::fetch($p_recordSet);
		if (!is_array($this->m_data['meta']) && $res) {
            // convert meta field
            if (empty($this->m_data["meta"])){
                $this->m_data["meta"] = array();
            } else {
                $this->m_data["meta"] = unserialize($this->m_data["meta"]);
            }
		}
		return $res;
	}
예제 #4
0
 /**
  * Fetch a single record from the database for the given key.
  *
  * @param array $p_recordSet
  *      If the record has already been fetched and we just need to
  *      assign the data to the object's internal member variable.
  *
  * @return boolean
  *      TRUE on success, FALSE on failure
  */
 public function fetch($p_recordSet = null)
 {
     $res = parent::fetch($p_recordSet);
     if ($this->exists()) {
         settype($this->m_data['IdPublication'], 'integer');
         settype($this->m_data['NrIssue'], 'integer');
         settype($this->m_data['NrSection'], 'integer');
         settype($this->m_data['IdLanguage'], 'integer');
         settype($this->m_data['Number'], 'integer');
         settype($this->m_data['IdUser'], 'integer');
         settype($this->m_data['LockUser'], 'integer');
         settype($this->m_data['ArticleOrder'], 'integer');
     }
     return $res;
 }
예제 #5
0
 /**
  * Fetch a single record from the database for the given key.
  *
  * @param array $p_recordSet
  *      If the record has already been fetched and we just need to
  *      assign the data to the object's internal member variable.
  *
  * @return boolean
  *      TRUE on success, FALSE on failure
  */
 public function fetch($p_recordSet = null, $p_forceExists = false)
 {
     $success = parent::fetch($p_recordSet);
     if ($success && $this->getType() == self::TYPE_NUMERIC) {
         $params = explode('=', $this->m_data['field_type_param']);
         if (isset($params[0]) && $params[0] == 'precision') {
             $this->m_precision = (int) $params[1];
         }
     }
     if ($success && $this->getType() == self::TYPE_BODY) {
         $params = explode('=', $this->m_data['field_type_param']);
         if (isset($params[0]) && $params[0] == 'editor_size') {
             $this->m_editorSize = (int) $params[1];
         }
     }
     if ($success && $this->getType() == self::TYPE_COMPLEX_DATE) {
         $params = explode(';', $this->m_data['field_type_param']);
         foreach ($params as $one_param) {
             $one_param_parts = explode('=', $one_param);
             if (isset($one_param_parts[1]) && $one_param_parts[0] == 'color') {
                 $this->m_colorValue = '' . $one_param_parts[1];
             }
         }
     }
     if ($success && !$this->getType()) {
         $params = explode(';', $this->m_data['field_type_param']);
         foreach ($params as $one_param) {
             $one_param_parts = explode('=', $one_param);
             if (isset($one_param_parts[1]) && $one_param_parts[0] == 'filter') {
                 $this->m_filterOut = (bool) ('' . $one_param_parts[1]);
             }
         }
     }
     return $success;
 }
예제 #6
0
    /**
     * Get the user from the database.
     *
     * @param array $p_recordSet
     *
     * @return void
     */
    public function fetch($p_recordSet = null)
    {
        global $g_ado_db, $LiveUserAdmin;

        $success = parent::fetch($p_recordSet);
        if ($success) {
            // find out LiveUser perm and auth identifiers
            $param = array('filters' => array('handle' => $this->m_data['UName']));
            $liveUserData = $LiveUserAdmin->auth->getUsers($param);
            if (is_array($liveUserData) && sizeof($liveUserData) > 0) {
                $this->m_liveUserData['auth_user_id'] = $liveUserData[0]['auth_user_id'];
                $params = array('filters' => array('auth_user_id' => $this->m_liveUserData['auth_user_id']));
                $permData = $LiveUserAdmin->perm->getUsers($params);
		if (is_array($permData) && sizeof($permData) > 0) {
		  $this->m_liveUserData['perm_user_id'] = $permData[0]['perm_user_id'];
		}
            }

            // fetch the permissions for this user
            if ($this->getUserType()) {
                $userType = new UserType($this->getUserType());
                if ($userType) {
                    $this->m_config = $userType->getConfig();
		    $this->m_exists = true;
                }
            } elseif ($this->getPermUserId()) {
                $queryStr = 'SELECT r.right_id as value, '
                                  .'r.right_define_name as varname '
                           .'FROM liveuser_users as u, '
                                .'liveuser_rights as r, '
                                .'liveuser_perm_users p, '
                                .'liveuser_userrights as l '
                           .'WHERE u.Id=p.auth_user_id AND '
                                .'p.perm_user_id=l.perm_user_id AND '
                                .'r.right_id=l.right_id AND '
                                .'p.perm_user_id='.$this->getPermUserId();
                $config = $g_ado_db->GetAll($queryStr);
                if ($config) {
                    // make m_config an associative array
                    foreach ($config as $value) {
                        $this->m_config[$value['varname']] = $value['value'];
                    }
                }
		$this->m_exists = true;
            }
        }
    } // fn fetch
예제 #7
0
파일: User.php 프로젝트: nidzix/Newscoop
 /**
  * Get the user from the database.
  *
  * @param array $p_recordSet
  *
  * @return void
  */
 public function fetch($p_recordSet = null, $p_forceExists = false)
 {
     global $g_ado_db;
     $success = parent::fetch($p_recordSet);
     if ($success) {
         $this->m_exists = true;
     }
 }
예제 #8
0
    /**
     * Fetch a single record from the database for the given key.
     *
     * @param array $p_recordSet
     *      If the record has already been fetched and we just need to
     *      assign the data to the object's internal member variable.
     *
     * @return boolean
     *      TRUE on success, FALSE on failure
     */
	public function fetch($p_recordSet = null)
	{
		$success = parent::fetch($p_recordSet);
		if ($success && $this->getType() == self::TYPE_NUMERIC) {
			$params = explode('=', $this->m_data['field_type_param']);
			if (isset($params[0]) && $params[0] == 'precision') {
				$this->m_precision = (int) $params[1];
			}
		}
		return $success;
	}