/** * Save a storage usage entity to the database * * @param StorageUsage $usage * @return boolean */ public function save(StorageUsage $usage) { $query = $this->db->prepareQuery('INSERT INTO *PREFIX*uc_storageusage (created, username, `usage`, maximumusage) VALUES (?,?,?,?)'); $result = $query->execute(array($usage->getDate()->format('Y-m-d H:i:s'), $usage->getUsername(), $usage->getUsage(), $usage->getMaximumUsage())); /* * $query->execute could return integer or OC_DB_StatementWrapper or false * I am expecting an integer with number 1 */ if (is_int($result) && $result === 1) { return true; } return false; }
/** * @param StorageUsage $storageUsage * @return Storage */ private function mapStorageUsageToStorageInformation(StorageUsage $storageUsage) { return new Storage($storageUsage->getUsage(), $storageUsage->getUsername(), $storageUsage->getMaximumUsage()); }