|
@@ 132-145 (lines=14) @@
|
| 129 |
|
protected function getConnection() { |
| 130 |
|
$shmKey = ftok($_SERVER['PHP_SELF'], 'c'); |
| 131 |
|
|
| 132 |
|
if (@$shmId = shmop_open($shmKey, "a", 0, 0)) { |
| 133 |
|
// Gets shared memory block's size. |
| 134 |
|
$shmSize = shmop_size($shmId); |
| 135 |
|
|
| 136 |
|
// Now lets read the memory segment. |
| 137 |
|
if ($buffer = shmop_read($shmId, 0, $shmSize)) |
| 138 |
|
$connection = unserialize($buffer); |
| 139 |
|
else |
| 140 |
|
throw new \RuntimeException("You are not connected to the server."); |
| 141 |
|
|
| 142 |
|
shmop_close($shmId); |
| 143 |
|
} |
| 144 |
|
else |
| 145 |
|
throw new \RuntimeException("You are not connected to the server."); |
| 146 |
|
|
| 147 |
|
return new Couch(new CurlAdapter($connection['server'], $connection['user'], $connection['password'])); |
| 148 |
|
} |
|
@@ 158-171 (lines=14) @@
|
| 155 |
|
protected function getDatabase() { |
| 156 |
|
$shmKey = ftok($_SERVER['PHP_SELF'], 'd'); |
| 157 |
|
|
| 158 |
|
if (@$shmId = shmop_open($shmKey, "a", 0, 0)) { |
| 159 |
|
// Gets shared memory block's size. |
| 160 |
|
$shmSize = shmop_size($shmId); |
| 161 |
|
|
| 162 |
|
// Now lets read the memory segment. |
| 163 |
|
if ($buffer = shmop_read($shmId, 0, $shmSize)) |
| 164 |
|
$database = $buffer; |
| 165 |
|
else |
| 166 |
|
throw new \RuntimeException("No database selected."); |
| 167 |
|
|
| 168 |
|
shmop_close($shmId); |
| 169 |
|
} |
| 170 |
|
else |
| 171 |
|
throw new \RuntimeException("No database selected."); |
| 172 |
|
|
| 173 |
|
return $database; |
| 174 |
|
} |