public function makeConnectorFromFile($fileName) { if (StringUtils::isEmpty($fileName)) { throw new Exception('Invalid db config file name: ' . $fileName); } @(include $fileName); if (StringUtils::isEmpty($configDbDsn) || StringUtils::isEmpty($configDbUsername) || StringUtils::isEmpty($configDbPassword)) { throw new Exception('Invalid db config file: ' . $fileName . "\n" . 'Remember that empty db passwords are not allowed!'); } return new DbConnector($configDbDsn, $configDbUsername, $configDbPassword); }
protected function init() { $requestString = file_get_contents('php://input'); if (StringUtils::isEmpty($requestString)) { return; } $requestData = XMLRPC_parse($requestString); $methodStrings = explode('.', XMLRPC_getMethodName($requestData)); $this->methodOwner = $methodStrings[0]; $this->methodName = $methodStrings[1]; $this->methodParams = XMLRPC_getParams($requestData); // TODO: Where to call session_start? session_start(); $this->session = new PhpHttpSession(); }
public function addEntry($caption, $author, $drawingString) { // TODO: Accept Entry object as parameter? // TODO: Validity checks here or in the server? if (StringUtils::isEmpty($caption)) { throw new InvalidParameterException("caption must not be empty."); } if (StringUtils::isEmpty($author)) { throw new InvalidParameterException("author must not be empty."); } if (StringUtils::isEmpty($drawingString)) { throw new InvalidParameterException("drawingString must not be empty."); } // TODO: Cache statement? $statement = $this->dbConn->getPdo()->prepare('INSERT INTO entries ( id, caption, author, drawingString, timestamp ) ' . 'VALUES ( NULL, :caption, :author, :drawingString, UTC_TIMESTAMP );'); $statement->execute(array(':caption' => $caption, ':author' => $author, ':drawingString' => $drawingString)); return $this->dbConn->getPdo()->lastInsertId(); }