HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Does ocPortal have a $db object?

Login / Search

 [ Join | More ]
 Add topic 
Posted
Item has a rating of 5 (Liked by Chris Graham)  
Rating:
#89203 (In Topic #18046)
Avatar

Community saint

Hi Chris,

I am working on some importers and while I notice that $db is used in most I have not found where that is being instantiated and am thinking it may come from the other CMS's db object. I just can't seem to find where that is being included? I could keep looking but I thought it'd probably be faster to just ask you.

I may have a couple more questions as I progress here but right now I am working on an ImportBuilder Class that is going to be very rudimentary at the moment but I hope to expand on over time making it more dynamic.

But what I intend to do in the initial phase for now is read all ocPortal config options into a temp table then read all config options of another CMS into a similar temp table and perform a match on names producing a temporary html output table of highest probable matches for config names to help in mapping config options from one CMS to another. This will make developing new importers a little easier I hope. In a future phase as I go to improve it I hope to have the output table of matches operate as a form with selectable fields as matches to actually automate the import rather than just using the output as a reference for developing the importer. But I just want to get the basic structure working as a output reference for now.

To perform config name matches I am breaking down ocPortal config names into an array of parts and searching each part against the other CMS config names the more parts that match the higher the probability of a config map success. ie:

max_AvatarWidth_upload would break down into the following parts (max, Avatar, Width, upload) which could receive a 100% probable match to UploadAvatar_maxWidth  but would only have a probability match of 75% to UploadAvater_maxHeight (I separate parts by Underscores and Camel Case)

I will sort my output by the top 4 matches probably.
Back to the top
 
Posted
Rating:
#89204
Avatar

IIRC $db is passed into importer hook methods as a parameter, so that those hooks don't need to worry about what that database connection is.

Generally in ocPortal we just access the DB from a global object, $GLOBALS['SITE_DB'] which is the same, generally.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: