/** * Connect with slave database via PDO connection. * * @return object */ public function getSlavePdo() { // if slave is not configured, divert to master instead if (empty($this->slaveConfig)) { $this->slave = $this->getMasterPdo(); // for multiple slaves, pick random slave } elseif ($this->app->arrIsIndex($this->slaveConfig)) { $this->slave = $this->createPdo($this->slaveConfig[array_rand($this->slaveConfig)]); // for single slave, only reconnect if not established previously } elseif (!$this->slave instanceof PDO) { $this->slave = $this->createPdo($this->slaveConfig); } return $this->slave; }
/** * Sending the the defined headers, if any. * Allow multiple headers with same type. * * @return \Avenue\Response */ public function sendDefinedHeaders() { foreach ($this->headers as $type => $format) { // processed as multiple headers for the same type // when format is provided as index based array if ($this->app->arrIsIndex($format)) { foreach ($format as $value) { header($type . ': ' . $value, false); } } else { header($type . ': ' . $format); } } return $this; }