URBANZ Posted March 26, 2021 Posted March 26, 2021 24 minutes ago, Sim said: Analytics would slow a site down even more IMO. Adding one additional query to every page load should not effect any performance at all. Update pageviews = pageviews +1 where page = thisPage This can be true in certain circumstances but from running analytics only spike i got is when i first added the code. but with adding an entry to the database every page load would definitely increase database size and personally just find unnecessary when analytics works so much better. also the data would be very inaccurate without extensive checking as 1 user could just be refreshing the page this would give you no actual data to go from. each person has their own opinion but i will always stick to analytics Quote
Sim Posted March 26, 2021 Posted March 26, 2021 We would be updating an entry every load. I doubt people have more then 100 pages on a game. So less then 100 entries top. Not much data. As far as a user keep refreshing, theres always an idiot, but that could always be fixed by only updating the view after an action in performed. Which would be better anyway since its about how often a feature is used, not viewed. Analytics is great. Very detailed, but this a very simple solution(which i woukd prefer to track how many times a feature is used) and don't need to lend your game to view it. I would reset it personally after new features are added or start new logging. And list % instead of just actions. Quote
Uridium Posted May 30, 2022 Author Posted May 30, 2022 Anyone Using this mod that could give some feedback or ideas 1 Quote
Uridium Posted July 11, 2023 Author Posted July 11, 2023 Is anyone using this mod do you have ideas for an upgrade Quote
Canjucks Posted July 11, 2023 Posted July 11, 2023 1 hour ago, Uridium said: Is anyone using this mod do you have ideas for an upgrade I don't even remember seeing this post but I like what you've done here. Quote
ags_cs4 Posted July 11, 2023 Posted July 11, 2023 i forgot i have this code, i played with it 2 years ago, but didnt make much of it, but its great, i might upgrade it to stop executing the hook files so if there is any db columns not found it wont give an error Quote
Uridium Posted September 22, 2024 Author Posted September 22, 2024 In my stupidness I forgot to add the CRONS for this too work so add this to your cron_minute.php file You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Extremlely sorry about that I know its been a few years since i added this mod I thought i Added the Cron aswell Quote
rockwood Posted September 23, 2024 Posted September 23, 2024 On 3/22/2021 at 3:14 AM, URBANZ said: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. I am very surprised that we are still using this kind of global variable in 2024. Why aren't we considering dependency injection? For Example: <?php // Define a Database Connection interface interface DatabaseConnectionInterface { public function connect(): PDO; } // Implement the Database Connection using PDO class DatabaseConnection implements DatabaseConnectionInterface { private string $host; private string $db; private string $user; private string $pass; public function __construct(string $host, string $db, string $user, string $pass) { $this->host = $host; $this->db = $db; $this->user = $user; $this->pass = $pass; } public function connect(): PDO { try { return new PDO("mysql:host={$this->host};dbname={$this->db}", $this->user, $this->pass); } catch (PDOException $e) { throw new Exception("Database connection error: " . $e->getMessage()); } } } // Define a User Repository that uses the Database Connection class UserRepository { private DatabaseConnectionInterface $dbConnection; // Constructor injection of the Database Connection public function __construct(DatabaseConnectionInterface $dbConnection) { $this->dbConnection = $dbConnection; } public function findUserById(int $id): ?array { $pdo = $this->dbConnection->connect(); $stmt = $pdo->prepare("SELECT * FROM users WHERE id = :id"); $stmt->execute(['id' => $id]); return $stmt->fetch(PDO::FETCH_ASSOC); } public function createUser(string $username, string $email): void { $pdo = $this->dbConnection->connect(); $stmt = $pdo->prepare("INSERT INTO users (username, email) VALUES (:username, :email)"); $stmt->execute(['username' => $username, 'email' => $email]); } } // Client code to use the repository function main() { // Database credentials $host = 'localhost'; $db = 'your_database'; $user = 'your_username'; $pass = 'your_password'; // Create a Database Connection instance $dbConnection = new DatabaseConnection($host, $db, $user, $pass); // Inject the Database Connection into UserRepository $userRepository = new UserRepository($dbConnection); // Example: Create a new user $userRepository->createUser('john_doe', '[email protected]'); // Example: Find a user by ID $user = $userRepository->findUserById(1); print_r($user); } // Run the main function main(); Quote
URBANZ Posted September 23, 2024 Posted September 23, 2024 13 hours ago, rockwood said: I am very surprised that we are still using this kind of global variable in 2024. Why aren't we considering dependency injection? well me too but also that post is from 2021 and for a specific engine which uses globals. I have a custom version of GL which uses full dependancy injection/routing etc as the engine is a bit dated now. Quote
rockwood Posted September 24, 2024 Posted September 24, 2024 10 hours ago, URBANZ said: well me too but also that post is from 2021 and for a specific engine which uses globals. I have a custom version of GL which uses full dependancy injection/routing etc as the engine is a bit dated now. Ah okay Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.