@makemykb - Blesta plugin database connection help
As some of you know, I took over @makemykb from @SmallWeb and as part of my roadplan I would like to have an automatic import of the articles and categories created.
I’m looking for someone who has some knowledge of doing Blesta plugin/module/coding work to help me get started with how I connect to the database, using ”native” Blesta code.
I think I can take it from there myself, as I figure out how I would handle the articles/categories.
It might be more work in the future, if so, it will be paid work. Not much as this is pro-bono work but it will give you that warm fuzzy feeling around your heart.
No, not an heart-attack.
Comments
That's a good idea.
I searched the Blesta blog and their last post around the subject was 2008
https://www.blesta.com/2008/04/21/importing-data-into-blesta/
Michael
That could be useful if I had a Blesta license.
Perhaps their trial license key works? Lets try.
I also read this https://docs.blesta.com/display/dev/Database+Access and that is useful, if I knew what type of class/object/reference or whatever to start with.
https://clients.mrvm.net
You should probably be able to do just as they explain in their documentation and use
$this->Record
to access the database.I'm not entirely sure, but since you inherit your plugin from the abstract class
Plugin
, you inherit some basic Blesta functionality with that. Part of that functionality seems to be theRecord
object. A quick search lead me here which looks like you'd need to callLoader::loadComponents
should the database object not be there. Then again, the Blesta docs suggest you should callLoader::loadComponents
from your constructor anyway.@Solaire thanks!
Guess I need to include the init.php and then get going. I hope
https://clients.mrvm.net
You need blesta license my friend? I got a bunch for you
Nexus Bytes Ryzen Powered NVMe VPS | NYC|Miami|LA|London|Netherlands| Singapore|Tokyo
Storage VPS | LiteSpeed Powered Web Hosting + SSH access | Switcher Special |
You're welcome
Not sure what you mean with include
init.php
since the docs don't mention this file? Since the plugin is included by Blesta you don't necessarily need to include anything, since Blesta already takes care of that.Also, while accessing the database directly is definitely something that would work, the better way is using their Model classes and controllers as documented here or, alternatively, their API should this support accessing the articles. This is less error prone since database changes wouldn't affect your plugin.
I'm absolutely not familiar with Blesta so I wouldn't know what Model to access, but looking at the Knowledge Base plugin should give you a clue