Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Skąd bierze się NULL char przy serializacji sesji?
viking
post
Post #1





Grupa: Zarejestrowani
Postów: 6 381
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Mam problem z zapisem zserializowanych danych sesji do BD.
Serializowana jest zwykła encja użytkownika

  1. namespace User\Entity;
  2.  
  3. class User {
  4. protected $id;
  5. ...
  6. //dalej settery/gettery
  7. }


INSERT powodował urwanie zapytania zaraz przed nazwą id (s:44:" - tutaj kończyły się dane). Owrapowałem to wokół jsen_encode i okazuje się że jest tam
Cytat
;s:44:\"\u0000User\\Entity...


Skąd to się bierze w tym kodzie?

Ten post edytował viking 25.10.2016, 08:51:00
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kapslokk
post
Post #2





Grupa: Zarejestrowani
Postów: 965
Pomógł: 285
Dołączył: 19.06.2015
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Chyba z serialize - http://php.net/manual/en/function.serialize.php

Cytat
Object's private members have the class name prepended to the member name; protected members have a '*' prepended to the member name. These prepended values have null bytes on either side.

Cytat
Returns a string containing a byte-stream representation of value that can be stored anywhere.
Note that this is a binary string which may include null bytes, and needs to be stored and handled as such. For example, serialize() output should generally be stored in a BLOB field in a database, rather than a CHAR or TEXT field.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.10.2025 - 02:22