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.

[Solved] Help with querybuilders GetSelect needed

R_JR_J Ex-FanboyMunich Admin
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?

Best Answer


  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @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!)

  • Options

    @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.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    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 ;-)

  • Options
    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.