Problem using ActiveRecord Class from Wiki - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem using ActiveRecord Class from Wiki (/showthread.php?tid=15662) |
Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]mambe churchill nanje[/eluser] Hello can someone help me out here with this ActiveRecord http://codeigniter.com/wiki/ActiveRecord_Class/ class usage, here is a link to a site am working on, a simple cms I built has this news section http://www.mpyraa.org/en/cms/newscontroller/ the page works well in localhost but on the server like you must have observed it says Quote:A Database Error Occurred The code that runs the controller is as follow: Code: <?php can someone tell me why this Code: $this->news->ordering('id','desc')->find_and_limit_by($perpage,$offset); Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]TheFuzzy0ne[/eluser] Sounds more to me like an issue with Database versions than PHP versions. Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]xwero[/eluser] the load->model method doesn't return an object so you your news variable can't be used to query the database. I don't know why it works on your localhost but it's a bad construction because CI appends an object to the controller with the name news because the model is named news. The best solution is to create a method in your news model that gets a part of the table. Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]mambe churchill nanje[/eluser] well on localhost I use mysql 4 and on the server its mysql 5 but I dont think that could be the problem IMHO, I am not mysql guru As for the Model not returning and object I dont think it changes anything, but BTW this is a Model that extends activerecords class in the wiki, check my model below Code: <?php and in the wiki page I posted earlier for this active record class they actually put $news = &$this->load->model('news') style of code then later you reference $news->delete() or soo But I wonder why its not working, any ActiveRecord Guru ?? I am checking active record on kohana and I might port the app to Kohana and then use the active record there, but I want it to work in CI because its already done please any help guys ?? Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]xwero[/eluser] I checked out the Active record class and is seems to be an ORM class. i think you better use a more mature ORM. Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]TheFuzzy0ne[/eluser] I think the problem is that you are using 'news.*' in your query, and I'm not sure if MySQL 4 supports select calls in this fashion. My suggestion would be to run that SQL statement at the MySQL CLI if you can, and see what it says. Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]mambe churchill nanje[/eluser] well @xwero can you please point me to a more mature ORM class ?? @TheFuzzyOne, localhost I am using mysql 4 and the query "news.*" worked just fine, on the server its mysql 5 and it fails. Also the sql gets generated by the ORM class, soo I dont have the SQL written to take and test someone. Could that be the issue Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]TheFuzzy0ne[/eluser] I'm going to just suggest that you try a new library as xwero suggested. I can't vouch for it as I've never used it, and I can't think of any other possible solutions. Problem using ActiveRecord Class from Wiki - El Forum - 02-11-2009 [eluser]mambe churchill nanje[/eluser] tomorrow I will definitely port the codes to kohana and use their ORM instead or maybe take the Kohana ORM and use in codeigniter thanks guys Problem using ActiveRecord Class from Wiki - El Forum - 02-12-2009 [eluser]mambe churchill nanje[/eluser] well I managed to tweak the ORM class from the wiki to do just what I needed it. normally the way I use it now, I deactivated the use of HAS_MANY and all the other relationship related ORM. I adjusted the code from this Code: /** Code: /** |