How to put no limit in database- codeigniter

Multi tool use
How to put no limit in database- codeigniter
I am using this to get results from a database, but it limits to 1 record.
I don't want any limit; I tried removing it but that doesn't work .
$this->db->from('links');
$this->db->where('uniq', $nnn[0]->uniq);
$this->db->limit(1);
$q = $this->db->get();
$nnn[0]->linkos=$q->result()[0];
return $nnn;
$this->db->limit(1);
dont work , i mean that dont effect anything ,
– Asokh Roy
Nov 8 '17 at 22:28
try printing sql query, and check what's final query being generated. stackoverflow.com/questions/6142099/…
– shyammakwana.me
Nov 8 '17 at 22:30
How many results are in the database where the column
uniq
is equal to whatever the value of $nnn[0]->uniq
is?– Goose
Nov 8 '17 at 22:43
uniq
$nnn[0]->uniq
remove: $this->db->limit(1); update: from: $nnn[0]->linkos=$q->result()[0]; to: $nnn[0]->linkos=$q->result();
– Mark
Nov 8 '17 at 22:49
1 Answer
1
$q->result()
Thus, leaving out the [0] part seems like a first step I would try in your case:
$nnn[0]->linkos=$q->result();
Sidestep:
$this->db->query("SELECT * FROM table WHERE...")
leaving out the [0] - not worked, before it gets data of only 1 , after removing o it dont get any data , and i am using a complex system if i change nything need to change in all , so if you can give me any fix for this code ony , without changing much would be great
– Asokh Roy
Nov 8 '17 at 22:55
Could you please describe your use case a little more? What is the starting situation? Why do you have to query the database, what are you trying to achieve with the results? Also some DDL for the tables would be nice.
– RvT
Nov 8 '17 at 22:59
the code i am using giving me only results of 1 row , other rows i cant get. now main thing is via uniue it connect with 2 different things, uniq works as a relation between to data, ( mean uniq is same in both ) .
– Asokh Roy
Nov 8 '17 at 23:07
I think that the limitation will be set in the WHERE clause, which is set in the
$this->db->where('uniq', $nnn[0]->uniq);
statement. Perhaps you could first try checking the value for the uniq
property for the first object in the $nnn
-array. See if it makes any sense. If it does, try running an explicit SQL statement, separately from CodeIgniter; perhaps you've got a MySQL prompt available. Thinking about it, it seems that the second line (containing the WHERE clause) should limit the resultset to just one row (intended behaviour). The third line seems like an extra safety measure.– RvT
Nov 8 '17 at 23:22
$this->db->where('uniq', $nnn[0]->uniq);
uniq
$nnn
@RvT - You are wrong to say
result()
returns an object. It returns an array - an array of objects. result_array()
returns and array of arrays.– DFriend
Nov 9 '17 at 2:44
result()
result_array()
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
what happens if you remove this line
$this->db->limit(1);
?– shyammakwana.me
Nov 8 '17 at 22:27