Active Record and SQL error |
[eluser]al404[/eluser]
i'm using Active Record Class to get data from a table but something is going wrong, and i just get a general error but i would need to see the SQL passed and /or the MySql error how can i get it? in db config file is $db['default']['db_debug'] = TRUE;
[eluser]PowerCode[/eluser]
You'll need to give more information. Specifically, the error that you get (even if it's general, since not everyone might know what it really is, like me ![]()
[eluser]al404[/eluser]
i didn't post the error messag because it is traslate.... if i reset to english it is A Database Error Occurred The query you submitted is not valid. the problm was caused by $this->db->select_max(100); i thoght that this was needed to add a LIMIT at the query
[eluser]Michael Wales[/eluser]
The ActiveRecord documentation clearly states: Quote:$this->db->select_max(); Absolutely nothing concerning a LIMIT, nor does it expect you to pass an integer parameter (instead it needs a field, so it can select the maximum value for that field within the table). On the other hand: Quote:$this->db->limit(); I'm really not trying to be cynical here and this is rare of me but come on people... at least try.
[eluser]al404[/eluser]
i found my error but the point is that i didn't get an output of the query (sql genereted) or of mysql like "you have an error near..." this way is very hard to find where is the error, i try adding comments before different peace of code
[eluser]aruna[/eluser]
hi, i m having the following error .The error is because of the usage of the operator >= in the query $this->db->where("sn.version_ts>=",recentdate); will anyone solve it please..... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1999-04-27' GROUP BY `sn`.`id` ORDER BY `sn`.`version_ts` DESC LIMIT 50' at line 4 SELECT `sn`.`id`, `sn`.`title`, `ln`.`id` as lid, `ln`.`name` as lname, `ln`.`slug` as lslug FROM (`snippet` as sn) JOIN `language` as ln ON `sn`.`language_id`=`ln`.`id` WHERE `sn`.`version_ts>=` '1999-04-27' GROUP BY `sn`.`id` ORDER BY `sn`.`version_ts` DESC LIMIT 50
[eluser]Armchair Samurai[/eluser]
Put a space between your column and your operation. Code: $this->db->where(“sn.version_ts >=”,recentdate);
[eluser]aruna[/eluser]
[quote author="Armchair Samurai" date="1236249570"]Put a space between your column and your operation. Code: $this->db->where(“sn.version_ts >=”,recentdate); ya ..Now i got it....Now its working... But i m getting some other error... Parse error: syntax error, unexpected T_STRING in /home/ntdg/public_html/codeigniter/system/plugins/dompdf/include/dompdf.cls.php(277) : eval()'d code on line 692 The code works well for other cases..but when i clicked the month april i m getting this error.. following s the controller..to_pdf_file($month)...when i selected a month from my interface(views) function to_pdf_file($month) { $snippet["codedetails"]=$this->Admin_Model->get_all_code_bymonth($month); $snippet["month"]=$month; $html=$this->load->view("view_pdf",$snippet,true); pdf_create($html,'Month',TRUE); } the following in my views(view_pdf) <? if($codedetails){ ?><ol> <? ?> <table border="1" width="200"> <tr><th>ID</th><th>TITLE</th><th>DESCRIPTION</th><th>CODE</th><th>VERSION</th></tr> <?foreach($codedetails as $s=>$ss){?> <tr> <td> <?=$ss['id'];?> </td> <td> <?=$ss['title'];?> </td> <td > <?=$ss['description'];?> </td> <td> <?=$ss['code'];?> </td> <td> <?=$ss['version_ts'];?> </td> </tr> <?}?> </table> <? }else{?> <p>list is empty</p> <? } ?> its not working for the month march.........please anyone resolve it......... when i selected the month april , i m getting the error as Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 39 bytes) in /home/ntdg/public_html/codeigniter/system/plugins/dompdf/lib/class.pdf.php on line 2373 please anyone resolve this too.....
[eluser]richie123[/eluser]
hi all I got a prolem, in my model, I select a limited record set as following line Code: if(!is_null($offset)) in this case, my $offset = 0, and the output query is generated like this Code: SELECT * FROM (`user`) LIMIT 1 instead of Code: SELECT * FROM (`user`) LIMIT 0, 1 so the question is : where is my $offset variable? is there some thing wrong with my code or it a bug of CI???
[eluser]nzmike[/eluser]
Having no offset and an offset of 0 and are the same thing aren't they? |
Welcome Guest, Not a member yet? Register Sign In |