ereg_replace issue

  • dmc_gryphonit
  • Newbie
  • Newbie
  • dmc_gryphonit
  • Posts: 12

Post 3+ Months Ago

hi there people

i have this code happening with regards to my wamp server. is this something that can be sorted out? would this happen on a normal remote server that has lamp on with the necessary bells and whistles?
Code: [ Select ]
Deprecated: Function ereg_replace() is deprecated in C:\wamp\www\itinwales\common\classes\class.paging.php on line 22


this is the code on line 22

Code: [ Select ]
$query = ereg_replace("^SELECT[[:space:]+]","SELECT SQL_CALC_FOUND_ROWS ",$query);


i have not come across coding like this before. is there a way that this can be written to work better or just to atually work?

cheers
  • dmc_gryphonit
  • Newbie
  • Newbie
  • dmc_gryphonit
  • Posts: 12

Post 3+ Months Ago

hi there

i have tried using the code instead

Code: [ Select ]
$query = "SELECT ";
$query = preg_replace("/^SELECT +/i","$0 SQL_CALC_FOUND_ROWS ",$query);
echo $query;
  1. $query = "SELECT ";
  2. $query = preg_replace("/^SELECT +/i","$0 SQL_CALC_FOUND_ROWS ",$query);
  3. echo $query;


but it brought up more errors.

i am using 5.0.4 on the remote server and 5.3.0 on my wamp server. what is the best php version to use? (5.2.11?)

hi there

also this "SQL_CALC_FOUND_ROWS" is this a command of some sort? i have not seen this before. i am trying to trawl thru another persons php shop. i downloaded the whole shop from one server and trying to put it up on another server. this is one of the 5 errors i am coming up against. anyone had any experience with this?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

You can learn how to use the preg_replace function here:

http://php.net/manual/en/function.preg-replace.php

SQL_CALC_FOUND_ROWS is used with FOUND_ROWS() when you have a limit clause so that you can find out how many rows would have been returned if you didn't have the limit set. Here is a quick summary:

Quote:
A SELECT statement may include a LIMIT clause to restrict the number of rows the server returns to the client. In some cases, it is desirable to know how many rows the statement would have returned without the LIMIT, but without running the statement again. To obtain this row count, include a SQL_CALC_FOUND_ROWS option in the SELECT statement, and then invoke FOUND_ROWS() afterward


You can see some example usage here:

http://www.mysqlperformanceblog.com/200 ... ound_rows/
  • dmc_gryphonit
  • Newbie
  • Newbie
  • dmc_gryphonit
  • Posts: 12

Post 3+ Months Ago

cheers for that BWM. bookmarked and ready to digest

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 94 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.