public function log($error, $data = null) { is_string($data) or $data = Json::encode($data); $stmt = $this->_pdo()->prepare('INSERT INTO "Logs" ("time", "error", "data") VALUES (:time, :error, :data)'); $stmt->bindValue('time', date('Y-m-d H:i:s')); $stmt->bindValue('error', $error); $stmt->bindValue('data', $data); $stmt->execute(); return $this; }
public function put($data, $ttr = 0, $delay = 0, $pri = 9999, $tube = null) { $data = Json::encode($data); $len = strlen($data); // tu jest niezły mindfuck $data = preg_replace('#\\\\(u\\d{4})#', '\\\\\\\\\\\\\\\\$1', $data); $tube or $tube = $this->tube; $cmd = "use {$tube}\r\nput {$pri} {$delay} {$ttr} {$len}\r\n{$data}"; $data = $this->_netcat($cmd); if (strpos($data, 'INSERTED') === false) { throw new BeanstalkdException("Benstalkd put error, wrong response: '{$data}', command: '{$cmd}'", BeanstalkdException::PUT_ERROR); } return $this; }