Error limit Codeigniter

0

Hello everyone, Codeigniter Brasil, I have a query that returns everything perfect on localhost but the server does not return the way it was written.

It is to return 6 results but on the server it returns the amount that it finds best up to 6.

$this->db->limit(6);
$this->db->select("*");
$this->db->from("vips");
$this->db->join("anuncios", "anuncios.id = vips.idPostVip");
$this->db->order_by('RAND()');
return $this->db->get()->result_array();

Any tips?

Any PHP configuration?

Help me Rs.

Thank you.

    
asked by anonymous 28.12.2016 / 18:20

1 answer

1

Use this way:

public function exibeSugestaoHome()
{
    $this->db->limit(3);
    $this->db->select("*");
    $this->db->from("anuncios");
    $this->db->where("vip > ",0);
    $this->db->order_by('RAND()');
    return $this->db->get()->result_array();
}

can also be done by shuffling items by , shuffle :

public function exibeSugestaoHome()
{
    $this->db->limit(3);
    $this->db->select("*");
    $this->db->from("anuncios");
    $this->db->where("vip > ",0);
    $result = $this->db->get()->result_array();
    shuffle($result);
    return $result;
}

The difference of the presented forms that the first shuffles the items straight into the table, and the second only in the results obtained. Depending on the situation one of them fits.

    
28.12.2016 / 19:10