Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

mysql query help

edited September 2010 in Vanilla 2.0 - 2.8
Iam trying to select some rows in a table that i have created. The table is called News (actually GDN_News).

I have made a model like this
class NewsModel extends CommunityModel { public function __construct() { parent::__construct(''); } public function Get($Offset = '0', $Limit = '15', $Wheres = '', $AdditionalFields = NULL) { $Offset = !is_numeric($Offset) || $Offset < 0 ? 0 : $Offset; $this->SQL ->Select('*') ->From("News"); // $this->SQL->Where($Wheres); $Data = $this->SQL ->OrderBy('NewsID', 'desc') ->Limit($Limit, $Offset) ->Get(); return $Data; } }

Then i try to get the data in my controller like this

$NewsModel = new NewsModel(); $this->NewsList = $NewsModel->Get($Offset, $Limit); print_r($this->NewsList); $this->SetData('NewsList', $this->NewsList);

But print_r($this->NewsList) returns this

object(Gdn_DataSet)#32 (6) { ["Connection"]=> object(PDO)#17 (0) { } ["_Cursor:private"]=> int(-1) ["_DatasetType:protected"]=> string(6) "object" ["_EOF:protected"]=> bool(false) ["_PDOStatement:private"]=> object(PDOStatement)#31 (1) { ["queryString"]=> string(48) "select * from GDN_News News order by NewsID desc" } ["_Result:protected"]=> NULL }

As you can see the queryString says from GDN_News News, why? (does it matter?). The _Result property is also NULL so i guess it is notgetting my data.

What am i doing wrong?

Any help is really appreciated!
Tagged:

Comments

  • Well trying different stuff i got it right.

    I needed to call the Result() method.

    print_r($this->NewsList->Result());
Sign In or Register to comment.