VB Schemes? External MySql DB connection? Integration?

9 posts by 2 authors in: Forums > CMS Builder
Last Post: March 7, 2008   (RSS)

Re: [void] VB Schemes? External MySql DB connection? Integration?

By Dave - March 5, 2008

Both are possible, but might require a bit of effort or custom code to get working right. There's some support for connecting to external databases, but it's not documented or well tested.

What features of CMS Builder do you want to use on the VB database? Do you want to be able to edit the records through CMS Builder? Or just display them in the viewers? Or use the search features?

There's a few options. Let me know more about how you want them to work together and we'll see what we can figure out.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] VB Schemes? External MySql DB connection? Integration?

By void - March 5, 2008

Hi Dave,

I'm only looking to do read only stuff. I'd better leave the editing to vbulletin :)

Any examples on how to do that?

Re: [void] VB Schemes? External MySql DB connection? Integration?

By Dave - March 5, 2008

If it's read only, maybe you could do a direct MySQL query? Something like this:

<?php
mysql_connect('hostname', 'username', 'password');
$result = mysql_query("SELECT * FROM yourTableName ORDER BY yourSortField");
if (!$result) { die("MySQL Error: ". htmlspecialchars(mysql_error()) . "\n"); }
while ($record = mysql_fetch_assoc($result)):
?>

Title: <?php echo $record['title']; ?><br/>
... display other fields here ...

<?php endwhile ?>


Would that work for you?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] VB Schemes? External MySql DB connection? Integration?

By void - March 6, 2008 - edited: March 6, 2008


Would that work for you?

That is how I do it today. Thanks.

Re: [void] VB Schemes? External MySql DB connection? Integration?

By Dave - March 6, 2008

Ok, I just want to make sure I'm answering your question correctly.

Was there some feature from CMS Builder that you wanted to use that did more than a straight MySQL query? If there is let me know how you want it to be different from what you have now and I'll try and figure it out for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] VB Schemes? External MySql DB connection? Integration?

By void - March 6, 2008 - edited: March 6, 2008

Hi Dave,

Yes, I wanted to map the VB DB and use CB's presentation engine to generate various scripts.

Btw, does CB support lister/viewer generation? Like when you click an item in a list of articles and read the selected article?

And can the menu items be hierarchical?

Thanks

Re: [void] VB Schemes? External MySql DB connection? Integration?

By Dave - March 6, 2008

Yes, CMS Builder lets you generate code for "list viewers" and "page viewers". Where the "list viewer" shows the list of records with paging and the "page viewer" shows one specific record.

You'd have to do some experimenting but I think basically all you'd need to do to use the VB tables in the viewers is set the tablename to your VB table and clear the table_prefix. In your viewer code you'll see a line like this:

$options['tableName'] = 'news';

Replace that with this:

$TABLE_PREFIX = "";
$options['tableName'] = 'nameOfYourVBTable';


And it should work just fine. That assumes all the tables are in the same database. If they're not you'd just need to connect to the other database with one line first.

>And can the menu items be hierarchical?

There's a few workarounds in the forum but there's no built in support for hierarchical records or subcategories yet.

Hope that helps, any other questions just let me know.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] VB Schemes? External MySql DB connection? Integration?

By void - March 7, 2008

I have no more questions. For now :) Thank you for your efforts, Dave. It is much appreciated.