public function setTitle($value) { $this->title = $value; $this->setUrlfriendlytitle(Format::friendlyTitle($this->title)); }
private function addPlayers(array $players, $start, $batch) { $start *= $batch; $sqlUserMain = 'INSERT INTO core_user (id, firstname, lastname, username, email, password, avatar_id, is_admin, is_dev, status, created_date, modified_date) VALUES '; $sqlUserItem = "(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, 1, NOW(), NOW())"; $sqlUserRoleMain = 'INSERT INTO core_user_role (user_id, role_id) VALUES '; $sqlUserRoleItem = '(%d, 5)'; $sqlPlayerMain = 'INSERT INTO bus_player (id, max_booking, level, is_caroussel, credits) VALUES '; $sqlPlayerItem = '(%d, 1, 0, 0, 10)'; $sqlMembershipMain = 'INSERT INTO bus_player_membership (player_id, membership_id) VALUES '; $sqlMembershipItem = '(%d, 1)'; $count = 0; $sqlUser = []; $sqlUserRole = []; $sqlPlayer = []; $sqlMembership = []; foreach ($players as $id => $player) { if ($id < 1) { continue; } $start--; if ($start >= 0) { continue; } $sqlUser[] = sprintf($sqlUserItem, $id, $player[1], $player[0], Util\Format::friendlyTitle($player[1] . '_' . $player[0]), uniqid() . '@gmail.com', Util\Security::encryptPassword('test')); $sqlUserRole[] = sprintf($sqlUserRoleItem, $id); $sqlPlayer[] = sprintf($sqlPlayerItem, $id); $sqlMembership[] = sprintf($sqlMembershipItem, $id); $count++; if ($count >= $batch) { break; } } $db = new Util\Data(); $db->execute($sqlUserMain . implode(',', $sqlUser)); $db->execute($sqlUserRoleMain . implode(',', $sqlUserRole)); $db->execute($sqlPlayerMain . implode(',', $sqlPlayer)); $db->execute($sqlMembershipMain . implode(',', $sqlMembership)); return $count . ' players added. '; }