Database Help

Urgulum

Joined: 2014-05-19
Posts: 7
Posted: Mon, 2014-08-04 19:33

Dear Reader,
I 'am write my first Gallery Module. So I get to the point where I need a Database connection to select, insert and delete rows.
Is the an up-to-date documentation about the Database Abstraction Layer ore any good example moduls out there?
Becaus the documentation I have found seem s to be out of date.
Thank you for your Help
Urgulum

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Mon, 2014-08-04 20:43
Urgulum wrote:
any good example moduls out there?

Depends. Most of the modules that quickly come to mind (outside of G3 core modules) serve to retrieve or reorganize data that's already in the db.

If the core doesn't provide the examples needed, maybe look at the custom fields module?
http://codex.galleryproject.org/Gallery3:Modules:custom_fields

The iptcedit module may help with select?
http://codex.galleryproject.org/Gallery3:Modules:iptcedit

 
spags

Joined: 2010-03-26
Posts: 120
Posted: Mon, 2014-08-04 21:51

I agree with tempg, the easient (but maybe not the best) way to figure this out is to look at the code in other modules. Some modules create database tables during their initialisation stage so that might be a good way to find out how to create or add records.

I also found that the API documentation on the Kohana site was helpful in that it gave me some idea of the functions available - not a lot of sample code but enough to get started. From memory G3 uses an older version of Kohana so you have to hunt around a bit for the older documentation. I don't recall what version it was though (2.6, 2.3, 2.36, something like that).

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2014-08-04 21:55

https://docs.google.com/document/pub?id=1DQ1Tz177aX5ZsSgEbjYtYOBufJ0SYhgYvfJtA6snn2Y

Copying existing modules is the way that I have been doing module dev that needed a new DB table.
In general you need a models directory in the module directory that has one file to extend the ORM.
then a installer helper to create the table(s)
then the controller or helper can do a db::build() query.

If you get stuck let us know what the final module will do so we can steer you in the right direction.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2014-08-04 21:58

Gallery 3 is built on top of Kohana 2.3.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Urgulum

Joined: 2014-05-19
Posts: 7
Posted: Tue, 2014-08-05 10:52

Dear tempg,
thank you for the two links to the modules. It helpt me a lot in combination with the documentation they have anserwd all my questions.

Urgulum

Dear Dave,
thank you. No I know that the documentaion is not out of date...
I m writing a replacment for the comments module. Because I wan t some functions that the comments module not provide. I decide to write my own because I like to write Computerprogramms and to take Photos. With Gallery I can combinate thes two hobys.( If you wan t I can post a link to my Page.)
So give me 2-5 hours and i can show you the first working Version.

Urgulum

 
Urgulum

Joined: 2014-05-19
Posts: 7
Posted: Tue, 2014-08-05 17:41

Okay. You can find the sorce here:
https://github.com/Urgulum/advcomment

It is a realy basic Version. Just for looking and testing. Don´t use it.
You can at the Momment add and View Comments. Also the Gravatar connection is working...
Tonight I write the moderation System and mayby the admin view.

Pleas remeber this is my first Gallery Module...

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sun, 2014-08-10 19:12

Nice.
I can't test it right now, but will when (IF) time permits.
It may have been an easier starting point to simply modify the comments module that G3 ships with (instead of the 2 modules linked above), but if it works, it works. I'd still recommend having a look at G3's default handling of comments.

If you post the final version (with feature list) in the forums, it may be welcomed by others as well.

Thanks for the contribution!

http://galleryproject.org/time-to-hibernate

 
Urgulum

Joined: 2014-05-19
Posts: 7
Posted: Sat, 2014-08-16 13:11

I have the same problem than you....
At the momment I use a not-easy-config Version on my own side. But I will write a easy-config Version and make it public.
If you wan´t you can see it her with a test comment: (please notice that my side is in german) http://schleierwelten.eu/index.php/Tiere/DSCF0462
Or without a comment: http://schleierwelten.eu/index.php/Pflanzen/P1000492