brantje / nextnote

A full Evernote / OneNote style WYSIWYG note editor for Nextcloud / ownCloud. Join our telegram at: https://t.me/NextNote
GNU Affero General Public License v3.0
163 stars 19 forks source link

Implement IQueryBuilder #83

Closed brantje closed 6 years ago

brantje commented 6 years ago

No idea how to do this, yet. We have docs but that just describes the methods.

Aim of this is better compatibility between different databases.

Pinging @MorrisJobke @icewind1991 @MorrisJobke @nickvergessen @jancborchardt How do i implement this in my app? Is there any example? Best would be a PR which modifies 1 entity, eg note for example. However i understand that, if you're busy that's not an option.

nickvergessen commented 6 years ago

I will do it

nickvergessen commented 6 years ago

ERROR: Permission to brantje/nextnote.git denied to nickvergessen. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Mind to add me?

brantje commented 6 years ago

Yes, one second

brantje commented 6 years ago

Done, you can join us by visiting this link =).

brantje commented 6 years ago

@nickvergessen How can i do a COUNT()? It's used here. Fixed. Final code:

    $this->qb->select('g.*', 'g.guid as guid', $this->qb->createFunction('COUNT(n.id) as note_count')) //'COUNT(n.id) as note_count'
            ->from('nextnote_groups', 'g')
            ->leftJoin('g','nextnote_notes','n',  $this->qb->expr()->eq('g.id', 'n.notebook'))->groupBy(['g.id']);
brantje commented 6 years ago

Fixed with 2749443f87146981d9939acd11945762b8146625

nickvergessen commented 6 years ago

Instead of as please use selectAlias()

brantje commented 6 years ago

So it becomes $this->qb->createFunction('COUNT(n.id)')->selectAlias('note_count')?

nickvergessen commented 6 years ago

Actually $this->qb->selectAlias($this->qb->createFunction('COUNT(' . $this->qb->getColumnName('n.id') . ')'), 'note_count')

Ps typed on phone, so no guarantee for typos

brantje commented 6 years ago

Perfect that works. Thanks.