/** * This method deletes UserCard row. * If it was active card, then is activated another * using activateBestLibraryCard method. * * @param UserCard $libCard * @return number $affectedRows */ public function deleteLibraryCardRow(UserCard $libCard, $activateAnother = true) { $affectedRows = $libCard->delete(); if ($activateAnother && $libCard->cat_username == $this->cat_username) { // Activate another card (if any) or remove cat_username and cat_password $this->activateBestLibraryCard(); } return $affectedRows; }