Noob Help Please! |
[eluser]Pascal Kriete[/eluser]
It's either get() or query(), not both. With active record you would use get(), in this case query() will return the query object directly: Code: // Change this Sorry if that confused you. I was referring to AR above.
[eluser]Randy Casburn[/eluser]
Change this: Code: function display($page){ to Code: function display($page){ $this->db->query runs the query. You don't need to $this->db->get() after it. Try that.
[eluser]Randy Casburn[/eluser]
Darn you're fast! (EYE see you've not change out your EYE yet ;-) )
[eluser]Pascal Kriete[/eluser]
:lol: , you're not too slow yourself. I'm contemplating making it two eyes and possibly a nose. But then, that would be a little to ordinary for my taste ![]()
[eluser]draconus[/eluser]
Now that i got this to the controller, I need to figure out how to open it up to the view Here is the controller: Code: <? And the View: Code: <html> and here is my current message using the code you just provided: A PHP Error was encountered Severity: Notice Message: Undefined variable: body Filename: views/page.php Line Number: 6
[eluser]Randy Casburn[/eluser]
Rockin' and rollin' now, but I think we probably led you astray again. We probably should have had you do a [edit]$query->result_array() since that will return an array of results. Then you can address them directly as a multi-dimensional array within your view if you'd like. Don't be afraid to check this in your view by doing: Code: <?php print_r('query'); ?> to see what's available for you to shout out on your view! Randy
[eluser]Randy Casburn[/eluser]
Wow...I'm tired....please look up $query->result_array() not query_array(). Sorry man. It's been a long day for me. $query->result_array() will give you an array of your result set. Randy
[eluser]Pascal Kriete[/eluser]
[Edit: Long post fail. Typing takes too long ![]() The data array keys turn into the view variables, so what you have access to right now is the $query variable. That $query variable is the array of row objects that the query returned. There are a few ways of getting query results. $query->result() returns an array of rows (I assumed it was more than one since you're grabbing 10). You could loop through that, leaving everything as it is: Code: <?php foreach($query): ?> Or you can use $query->row() to only get a single row. This still returns an object, so in your view you would echo $query->title, $query->body, etc (you can rename query to something more descriptive, of course). Code: return ($query->num_rows() > 0) ? $query->row() : FALSE; If all you have is body and title, you could also get an array instead of an object, so you can pass it straight in to the view: Code: // Model
[eluser]draconus[/eluser]
o, damn, take a look at this error: Fatal error: Call to undefined method CI_DB_mysql_driver::query_array() in /Users/draconus/Sites/draconus/new/application/models/site.php on line 34
[eluser]Randy Casburn[/eluser]
yea - read my corrections....I'm too tired. inparo has you fixed up. Sorry 'bout that. Randy |
Welcome Guest, Not a member yet? Register Sign In |