Thanks Susan and MattC, I was able to accomplish what I wanted by combining the tips
that both of you gave me.
I just had to put this in my details page:
------------------------------
[!loopDbChunk?
&chunkName=`DBtestingdetails`
&sql=`select * from my_db.my_table where mycollumn_name _eq_ ’[[snippetexamplebymatt]]’`
&perPage=`1`
&missingValTxt=`Pending`
!]
-----------------------------------
Is this secure?
Matt, when you say external database you mean that its located in another server or that it isnt
a table in the modx database? in my case its another database in the same server(localhost).
Suzan, I tried to load my db using one of the examples given in the wiki but it seems that modx
isnt able to locate it because it adds a modx prefix, it appears like this in the error: modx.my_db.my_table
Another tip I saw in the forums was to change the index.php?id=94 to [~94~] this
make it easier for friendly urls.
Hi,
In my use of the altered loopdbchunk, I am querying a non-MODx database on the same server. (At least I think it’s on the same server.) But it is a completely different database than the one MODx uses, as I want to keep website material and event data separate.
But to do that I had to modify loopdbchunk - see message #46 above - to use reqular php sql calls rather than what is built in to MODx. I seem to recall looking at the MODx query API and thinking that technically one could tell it to connect to another database, do a query and then reconnect to the MODx database. But I thought that might risk breaking something, so I just replaced the code to create what is in effect a "loopexdbchunk" (Loop External Database Chunk) routine.
Hope that helps,
MattC
hey thr how can i connect to my external database in same server. I have dbedit module
I played around with dbedit for a little while, but ended up using loopdbchunk. In both instances, I changed all the modx-specific database calls (e.g $modx->db) to their equivalent mysql calls. Then you need to add a few lines of code at the start to open the database, and a few at the end to close the database.
MattC
See posts earlier in thread.
MattC