Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-11-21 18:52:12

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

how do I connect to another non txp db?

I started writing this in the ‘How’ forum but I felt that although it has to do with txp, the main issue here might not be txp specific.

As you know from my request for advice on another thread, we are in the process of merging one of our sub-domains with our main domain. The one thing left which i am currently working on is our newsletter subscribers whom i will be moving to a new phplist install on another subdomain. Although we used phplist about 13 years ago, it is still a steep learning curve to get back into it.

I am currently trying to achieve two things, both of which seem beyond me.

  1. have the subscription fields and subscribe button in our main domain
  2. parse the number of subscribers and show that number next to the subscription form

Basically what I am trying is to substitute the content of this page with its equivalent. I have to admit here that the particular content is semi-fake. ie, the fields are generated by com_connect and the only real thing from the postmaster plugin is the number of subscribers which we parse by using <txp:php>echo getCount('bab_pm_subscribers',"1");</txp:php> and the rah_external_output plugin.

So the first question, of what threatens promises to be a long thread is, how do I connect to another database in the same server from within a page of a txp install?

Many thanks in advance should anybody can share some light.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2018-11-21 19:15:14

etc
Developer
Registered: 2010-11-11
Posts: 5,189
Website GitHub

Re: how do I connect to another non txp db?

colak wrote #315376:

So the first question, of what threatens promises to be a long thread is, how do I connect to another database in the same server from within a page of a txp install?

Hi Yiannis,

IIRC, you can do it with etc_query, e.g.

<txp:etc_query url="other_db_name" markup="db" data="SELECT a, b, c FROM some_table">
    {a?}*{b?}={c?}
</txp:etc_query>

Offline

#3 2018-11-21 19:19:24

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: how do I connect to another non txp db?

The good news is you can do this mid-page with rah_swap. It’s pretty straightforward as long as the db is on the same server, which is what you have.

If the other database is a non-txp database, you need something like smd_query to pull out the information you want, but it works. I’ve used this to build a company search interface using data in another database input using a separate piece of software on the same server. If you need to know specifics, I can show you an example off-forum.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2018-11-22 10:00:28

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: how do I connect to another non txp db?

Hi Julian,

Thanks so much for your help. I will write to you on Saturday as I feel that I would definitely need help on this one. I was hoping that mybe com_connect would be able to connect to that db regarding my first issue.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB