Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $router = new protectclassesRouter();
- $tmp = serialize($router);
- $dsn = 'pgsql:dbname=system;host=127.0.0.1';
- $user = 'postgres';
- $password = 'mypassword';
- $pdo = new PDO($dsn, $user, $password, $options);
- $pdo->exec('SET search_path = temporary');
- $pdo->query("SELECT replace_value('protectclassesRouter','$tmp','serialized_classes')"); // this is my function it`s work fine
- $tmp = addslashes(serialize($router));
- $sth = $pdo->prepare('SELECT replace_value(?, ?, ?)');
- $sth->execute(array('protectclassesRouter', $tmp, 'serialized_classes'));
- $sth = $pdo->prepare('SELECT replace_value(:router, :serialbytes, :mode)');
- $sth->bindParam(':router', 'protectclassesRouter');
- $sth->bindParam(':mode', 'serialized_classes');
- $sth->bindParam(':serialbytes', $tmp, PDO::PARAM_LOB);
- $sth->execute();
- use ZendSerializerAdapterPhpSerialize;
- /**
- *
- * Class overloads serialization methods so serialized objects will be PostgreSQL safe
- * For further information on safe/unsafe objects:
- * http://php.net/manual/en/function.serialize.php#96504
- *
- */
- class PostgresSerialize extends PhpSerialize {
- const DEFAULT_SAFE_NULLBYTE_REPLACEMENT = "~~NULL_BYTE~~";
- protected static $serializedFalse = null;
- public function serialize($value) {
- $serializedString = parent::serialize($value);
- if (strpos($this->options['safe_nullbyte_replacement'], $serializedString))
- throw new RuntimeException('Cannot perform safe nullbyte replace operation since safe_nullbyte_replacement="' . $this->options['safe_nullbyte_replacement'] . '"value already exists in the serialized string', ZendLogLogger::ERR);
- if ($this->options['safe_nullbyte_replacement'] == null)
- $this->options['safe_nullbyte_replacement'] = self::DEFAULT_SAFE_NULLBYTE_REPLACEMENT;
- return str_replace("