Skip to main content

Timeline for Users management php class

Current License: CC BY-SA 4.0

11 events
when toggle format what by license comment
Sep 1, 2018 at 15:54 vote accept user9741470
Jun 5, 2018 at 11:44 answer added shudder timeline score: 2
Jun 4, 2018 at 11:30 answer added Dan timeline score: 1
Jun 3, 2018 at 15:37 comment added user9741470 I've tested your suggestion about rowCount() and I've removed it by changing it with the fetchColumn(). I'm now working on the try{}catch{}, by adding an exception in every if or else statement where now there is an echo. All works fine, I'm posting the answer with a reworked version of the code, I'm sure it can be improved.
Jun 3, 2018 at 14:08 comment added Your Common Sense as of rowCount() for me it's a matter of sanity: you are selecting some data but not fetching it. For me, it makes no sense. At the same time rowCount() is not guaranteed to be available. After all, fetch() makes uniform processing
Jun 3, 2018 at 12:04 comment added Your Common Sense yes, it's a mistake. like any other tool, try catch has its use, and this is a perfectly legitimate case for it. All other ways to check for error would be more tedious and your current approach is just no-go. Please read my article on MVC, it explains, why a code in Model should never output a single character - you just cannot tell in which context it will be used in the future.
Jun 3, 2018 at 11:46 comment added user9741470 @YourCommonSense what about the email check instead, I've looked at your article, for now in the code I've implemented the $stmt->rowCount(), and work smoothly, do you think that $stmt->fetchColumn() it can be better for the script performances? For the exception I will go deeper about, but I don't like to use try{}catch{}, but maybe this is a mistake of mine.
Jun 3, 2018 at 11:33 comment added Your Common Sense Like I suggested before, the best would be to throw a custom exception, then catch it in the AJAX handling code (outside the class). There is an explanation i wrote in the other question (ider Error reporting section) codereview.stackexchange.com/questions/193023/…
Jun 3, 2018 at 11:24 comment added user9741470 @YourCommonSense I wrote echos because for now I didn't write the AJAX code to request the various class taskes such createUser ecc. so I need a simply output to show when something was wrong. I don't know if can be a good idea to sobstitute echos with return for now. The code will be implemented only for login scope but will no interact with other classes. any suggestion for replacing echos will be appreciated. I'm also planning to add a method to send verification email, but for now I'm evaluting on how to proceed.
Jun 3, 2018 at 11:18 comment added Your Common Sense I've got a little suggestion for checkEmail function. as of the rest, did you actually try to implement this class in the actual code? All those echos look terribly misplaced. Where such an output is supposed to be shown?
Jun 3, 2018 at 9:38 history asked user9741470 CC BY-SA 4.0