public function create()
	{
		$db = \App::get('db');

		$modifiedDate = gmdate('Y-m-d H:i:s');

		if (is_numeric($this->get('uidNumber')))
		{
			$query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) VALUE (" . $db->quote($this->get('uidNumber')) . ',' . $db->quote($this->get('username')) . ',' . $db->quote($modifiedDate) . ");";

			$db->setQuery($query);

			if (!$db->query())
			{
				$errno = $db->getErrorNum();

				if ($errno == 1062)
				{
					$this->setError('uidNumber (' . $this->get('uidNumber') . ') already exists' . ' in xprofiles table');
				}
				else
				{
					$this->setError('Error inserting user data to xprofiles table: ' . $db->getErrorMsg());
				}

				return false;
			}
		}
		else
		{
			$token = uniqid();

			$query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) SELECT " . "IF(MIN(uidNumber)>0,-1,MIN(uidNumber)-1)," . $db->quote($token) . ',' . $db->quote($modifiedDate) . " FROM #__xprofiles;";

			$db->setQuery($query);

			if (!$db->query())
			{
				$this->setError('Error inserting non-user data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			$query = "SELECT uidNumber FROM `#__xprofiles` WHERE username=" . $db->quote($token) . " AND modifiedDate=" . $db->quote($modifiedDate);

			$db->setQuery($query);

			$result = $db->loadColumn();

			if ($result === false)
			{
				$this->setError('Error adding data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			if (count($result) > 1)
			{
				$this->setError('Error adding data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			$this->set('uidNumber', $result[0]);
		}

		$this->set('modifiedDate', $modifiedDate);

		if ($this->update() === false)
		{
			return false;
		}

		return true;
	}
public function create()
	{
		$db = \App::get('db');

		$modifiedDate = gmdate('Y-m-d H:i:s');

		if (is_numeric($this->get('uidNumber')))
		{
			$query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) VALUE (" . $db->quote($this->get('uidNumber')) . ',' . $db->quote($this->get('username')) . ',' . $db->quote($modifiedDate) . ");";

			$db->setQuery($query);

			if (!$db->query())
			{
				$errno = $db->getErrorNum();

				if ($errno == 1062)
				{
					$this->setError('uidNumber (' . $this->get('uidNumber') . ') already exists' . ' in xprofiles table');
				}
				else
				{
					$this->setError('Error inserting user data to xprofiles table: ' . $db->getErrorMsg());
				}

				return false;
			}
		}
		else
		{
			$token = uniqid();

			$query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) SELECT " . "IF(MIN(uidNumber)>0,-1,MIN(uidNumber)-1)," . $db->quote($token) . ',' . $db->quote($modifiedDate) . " FROM #__xprofiles;";

			$db->setQuery($query);

			if (!$db->query())
			{
				$this->setError('Error inserting non-user data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			$query = "SELECT uidNumber FROM `#__xprofiles` WHERE username=" . $db->quote($token) . " AND modifiedDate=" . $db->quote($modifiedDate);

			$db->setQuery($query);

			$result = $db->loadColumn();

			if ($result === false)
			{
				$this->setError('Error adding data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			if (count($result) > 1)
			{
				$this->setError('Error adding data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			$this->set('uidNumber', $result[0]);
		}

		$this->set('modifiedDate', $modifiedDate);

		if ($this->update() === false)
		{
			return false;
		}

		return true;
	}
public function create ( ) { $ db = \ App :: get ( 'db' ) ; $ modifiedDate = gmdate ( 'Y-m-d H:i:s' ) ; if ( is_numeric ( $ this -> get ( 'uidNumber' ) ) ) { $ query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) VALUE (" . $ db -> quote ( $ this -> get ( 'uidNumber' ) ) . ',' . $ db -> quote ( $ this -> get ( 'username' ) ) . ',' . $ db -> quote ( $ modifiedDate ) . ");" ; $ db -> setQuery ( $ query ) ; if ( ! $ db -> query ( ) ) { $ errno = $ db -> getErrorNum ( ) ; if ( $ errno == 1062 ) { $ this -> setError ( 'uidNumber (' . $ this -> get ( 'uidNumber' ) . ') already exists' . ' in xprofiles table' ) ; } else { $ this -> setError ( 'Error inserting user data to xprofiles table: ' . $ db -> getErrorMsg ( ) ) ; } return false ; } } else { $ token = uniqid ( ) ; $ query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) SELECT " . "IF(MIN(uidNumber)>0,-1,MIN(uidNumber)-1)," . $ db -> quote ( $ token ) . ',' . $ db -> quote ( $ modifiedDate ) . " FROM #__xprofiles;" ; $ db -> setQuery ( $ query ) ; if ( ! $ db -> query ( ) ) { $ this -> setError ( 'Error inserting non-user data to xprofiles table: ' . $ db -> getErrorMsg ( ) ) ; return false ; } $ query = "SELECT uidNumber FROM `#__xprofiles` WHERE username=" . $ db -> quote ( $ token ) . " AND modifiedDate=" . $ db -> quote ( $ modifiedDate ) ; $ db -> setQuery ( $ query ) ; $ result = $ db -> loadColumn ( ) ; if ( $ result === false ) { $ this -> setError ( 'Error adding data to xprofiles table: ' . $ db -> getErrorMsg ( ) ) ; return false ; } if ( count ( $ result ) > 1 ) { $ this -> setError ( 'Error adding data to xprofiles table: ' . $ db -> getErrorMsg ( ) ) ; return false ; } $ this -> set ( 'uidNumber' , $ result [ 0 ] ) ; } $ this -> set ( 'modifiedDate' , $ modifiedDate ) ; if ( $ this -> update ( ) === false ) { return false ; } return true ; }
Create a new entry in the profiles table

@return  boolean  True on success, False on error
Create a new entry in the profiles table