Welcome Guest, Not a member yet? Register   Sign In
Typecasting in DB_active_rec::limit
#1

[eluser]0plus1[/eluser]
I upgraded today from 2.0 to 2.1 and I noticed that some of the queries where being interpreted by active record with LIMIT 0;

Now, I got accustomed during the years in doing this:

Code:
$this->model->x(false,false);

function x($limit,$offset){
...
$this->db->limit($limit,$offset);
}

to avoid setting a limit when I didn't want one (especially for debugging).

After searching (didn't found mention in the changelog) I discovered that the:

Code:
public function limit($value, $offset = '')

in

Code:
DB_active_rec.php
file now has typecasting.

Since

Code:
(int) false === 0

I got the limit 0.

I propose in the next version to change the function to:

Code:
/**
  * Sets the LIMIT value
  *
  * @param integer the limit value
  * @param integer the offset value
  * @return object
  */
public function limit($value, $offset = '')
{
  $this->ar_limit = ($value===false)?false:(int) $value;

  if ($offset != '')
  {
   $this->ar_offset = ($offset===false)?false:(int) $offset;
  }

  return $this;
}

Thank you for your consideration




Theme © iAndrew 2016 - Forum software by © MyBB