RobertP Posted June 13, 2012 Share Posted June 13, 2012 Just to inform everyone, time to move to PDO if you have not already. mysql_* functions are *soft deprecated* ... Quote Link to comment Share on other sites More sharing options...
Philip Posted June 13, 2012 Share Posted June 13, 2012 Or mysqli if your heart desires so. Quote Link to comment Share on other sites More sharing options...
Stooney Posted June 14, 2012 Share Posted June 14, 2012 The guy is right, many tutorials out there are going to break with 5.4. Quote Link to comment Share on other sites More sharing options...
scootstah Posted June 14, 2012 Share Posted June 14, 2012 The guy is right, many tutorials out there are going to break with 5.4. No they're not. mysql_* is not even deprecated yet. And even if it was it would still work in PHP5.4, albeit with an error message (which you can suppress). Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted June 14, 2012 Share Posted June 14, 2012 I have 5.4 and mysql works just fine Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 14, 2012 Share Posted June 14, 2012 If they remove the mysql_* extension functions as quickly as they removed register_globals, we're screwed! SCREWED I TELL YOU! Quote Link to comment Share on other sites More sharing options...
scootstah Posted June 14, 2012 Share Posted June 14, 2012 If they remove the mysql_* extension functions as quickly as they removed register_globals, we're screwed! SCREWED I TELL YOU! Hah, yeah. When they roll out PHP7.0 there will be a lot of pissed off newbies. Quote Link to comment Share on other sites More sharing options...
Hall of Famer Posted June 30, 2012 Share Posted June 30, 2012 Well those who are used to MySQL will need to live with the fact that PDO does not have an equivalent method PDO::num_rows() to replace mysql_num_rows(). Its quite annoying, but can be easily overcome with the usage of 'SELECT COUNT' statement. As far as I know, 'SELECT COUNT' is more efficient than mysql_num_rows(), although it does take much more typing. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted June 30, 2012 Share Posted June 30, 2012 Well those who are used to MySQL will need to live with the fact that PDO does not have an equivalent method PDO::num_rows() to replace mysql_num_rows(). Its quite annoying, but can be easily overcome with the usage of 'SELECT COUNT' statement. As far as I know, 'SELECT COUNT' is more efficient than mysql_num_rows(), although it does take much more typing. Uh... http://www.php.net/manual/en/pdostatement.rowcount.php Quote Link to comment Share on other sites More sharing options...
scootstah Posted June 30, 2012 Share Posted June 30, 2012 Well those who are used to MySQL will need to live with the fact that PDO does not have an equivalent method PDO::num_rows() to replace mysql_num_rows(). Its quite annoying, but can be easily overcome with the usage of 'SELECT COUNT' statement. As far as I know, 'SELECT COUNT' is more efficient than mysql_num_rows(), although it does take much more typing. Uh... http://www.php.net/manual/en/pdostatement.rowcount.php For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement. Instead, use PDO::query() to issue a SELECT COUNT(*) statement with the same predicates as your intended SELECT statement, then use PDOStatement::fetchColumn() to retrieve the number of rows that will be returned. You can also just do count($result->fetchAll()); Quote Link to comment Share on other sites More sharing options...
Philip Posted July 1, 2012 Share Posted July 1, 2012 Uh... http://www.php.net/manual/en/pdostatement.rowcount.php That won't get you a count from a select, just of recently affected rows. You can also just do count($result->fetchAll()); That's about the closest thing, however if you don't want to fetch all of the rows the select count will always be there for you. In a situation like this, one less query usually == better. Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 1, 2012 Share Posted July 1, 2012 In a situation like this, one less query usually == better. You could probably do a sub-select to get the total rows couldn't you? Seems a little weird though. Quote Link to comment Share on other sites More sharing options...
Philip Posted July 1, 2012 Share Posted July 1, 2012 Yeah, you could probably do. Quote Link to comment Share on other sites More sharing options...
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.