| @@ 112-126 (lines=15) @@ | ||
| 109 | * |
|
| 110 | * @return bool |
|
| 111 | */ |
|
| 112 | private function increment() |
|
| 113 | { |
|
| 114 | $query = $this->pdo->prepare(<<<SQL |
|
| 115 | INSERT INTO robotstxt__delay0 (base, userAgent, delayUntil, lastDelay) |
|
| 116 | VALUES (:base, :userAgent, (UNIX_TIMESTAMP(CURTIME(6)) + :delay) * 1000000, :delay * 1000000) |
|
| 117 | ON DUPLICATE KEY UPDATE |
|
| 118 | delayUntil = GREATEST((UNIX_TIMESTAMP(CURTIME(6)) + :delay) * 1000000, delayUntil + (:delay * 1000000)), |
|
| 119 | lastDelay = :delay * 1000000; |
|
| 120 | SQL |
|
| 121 | ); |
|
| 122 | $query->bindValue('base', $this->base, \PDO::PARAM_STR); |
|
| 123 | $query->bindValue('userAgent', $this->userAgent, \PDO::PARAM_STR); |
|
| 124 | $query->bindValue('delay', $this->delay, \PDO::PARAM_INT); |
|
| 125 | return $query->execute(); |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * Debug - Get raw data |
|
| @@ 133-145 (lines=13) @@ | ||
| 130 | * |
|
| 131 | * @return array |
|
| 132 | */ |
|
| 133 | public function debug() |
|
| 134 | { |
|
| 135 | $query = $this->pdo->prepare(<<<SQL |
|
| 136 | SELECT * |
|
| 137 | FROM robotstxt__delay0 |
|
| 138 | WHERE base = :base AND userAgent = :userAgent; |
|
| 139 | SQL |
|
| 140 | ); |
|
| 141 | $query->bindValue('base', $this->base, \PDO::PARAM_STR); |
|
| 142 | $query->bindValue('userAgent', $this->userAgent, \PDO::PARAM_STR); |
|
| 143 | $query->execute(); |
|
| 144 | return $query->rowCount() > 0 ? $query->fetch(\PDO::FETCH_ASSOC) : []; |
|
| 145 | } |
|
| 146 | } |
|
| 147 | ||