Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Skąd bierze się NULL char przy serializacji sesji?
Forum PHP.pl > Forum > PHP
viking
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?
kapslokk
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.
viking
Jeszcze znalazłem tutaj http://stackoverflow.com/questions/2140689...umn-in-database
Teraz tylko muszę znaleźć najlepszy sposób na zmianę kodu Zend\Session
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.