Results 1 to 5 of 5

Thread: Contao3: $this->User->filemounts from serialized 2 full path

  1. #1

    Default Contao3: $this->User->filemounts from serialized 2 full path

    The field filemounts in tl_users, tl_users_group has entry in DB like
    Code:
    a:3:{i:0;i:22;i:1;i:62;i:2;i:41;}
    But if you print out $this->User->filemounts you get an array
    Code:
    Array ( [62] => files/doc [22] => files/content [41] => files/framework )
    In which class and in which function is this conversion done?

    OK I found out
    Its in Class BackendUser->setUserFromDb()
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Contao3: $this->User->filemounts from serialized 2 full

    A method to find that if you don't know is to print_r($this->User). The method prints a lot of info and starts with the classname. If the printed info doesn't help you can use the classname and search for "class classname" in all files. This way you can easily find the function that does this.

  3. #3
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Contao3: $this->User->filemounts from serialized 2 full

    Looks like you have two questions.

    You have to serialize() and deserialize() data if you are going to directly write to the Database. Normally the Models/Database classes will handle this for you. You just assign the array to the value and it will be serialised before writing to the database. When you read it in though, you have to perform the deserialize() to get out into an array.

    In version 3, the ID is the new DBFS filesystem ID number must be converted by the FilesModel (you can inspect Controller, there are examples in there):
    Code:
    $objFile = \FilesModel::findByPk(62);
    if ($objFile !== null)
      echo $objFile->path
    To convert items from IDs to paths.

  4. #4

    Default Re: Contao3: $this->User->filemounts from serialized 2 full

    Thanks for answers: As I found out in Class BackendUser->setUserFromDb()

    Code:
    $objFiles = \FilesModel::findMultipleByIds(deserialize('a:3:{i:0;i:22;i:1;i:62;i:2;i:41;}'));
    $this->filemounts = $objFiles->fetchEach('path');
    did the job.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  5. #5
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Contao3: $this->User->filemounts from serialized 2 full

    thanks for posting the content. someone else might want that too.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •