Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

[Solved] Help with querybuilders GetSelect needed

R_JR_J Cheerleader & TroubleshooterMunich Moderator
edited August 2013 in Vanilla 2.0 - 2.8

I want to create a view in and found that instruction:

$View = $Database->Select('rp.*')   
   ->Select('p.Name', '', 'Permission')   
   ->From('RolePermission rp')
   ->Join('Permission p', 'rp.PermissionID = p.PermissionID')
$Construct->View('vw_RolePermission', $View);

So I try:

$Database = Gdn::Database();
$Sql = $Database->Select('*')->From('User')->GetSelect(); 

But I receive that error: Fatal error: Call to undefined method Gdn_Database::Select()

How can I use the GetSelect function to get back the SQL I need for creating the view?


  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    @x00: but GetSelect is the most Vanilla way to create a view, isn't it? I'm supposed to pass in a sql into the view function and I think it's better to build it and not to code it manually.

    My example was just an example. I want to join two (huge) tables I create in a plugin (and I just can wait to release it!)

  • @R_J said:
    x00: but GetSelect is the most Vanilla way to create a view, isn't it?

    Are you wanting to create a mySQL View? This is not the same as a view as in a controller view that renders a page.

    grep is your friend.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Yes, I've needed a view in the database and your first response was a perfect fit to my question, thanks for that!
    My problem from the opening posting is solved and I've already tested it.

    But I was just wondering if there is another way of creating a (database) view than the above mentioned, because you said that GetSelect is rarely used and I might use Get instead. I think you were meaning that more general, but because I want to learn, I thought I ask again to be sure ;-)

  • x00x00 MVP
    edited August 2013

    What I'm saying is very rarely are query strings directly needed outside this abstraction.

    Instead of database views there are also object caching options.

    grep is your friend.

Sign In or Register to comment.