The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue Nov 29, 2011 8:43 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Nov 29, 2011 8:22 pm
Posts: 43
Hello- I was hoping to get some help in the area of How to query SQL from Joomla 1.7? I really am a newbie when it comes to this area of working with databases thru Joomla.

I need to connect to an external database outside of the Joomla built in one. The external database houses a simple table with 5 columns of info. I want to query that database and showcase some of the info on the main index.php page of my joomla 1.7 site.

Anyone know of the best way to go about this process and can actually break it down into steps?

Here is the page in development.. dev.runkles.com

scroll down to the very bottom where you see New Insurance customers, Average Savings and Total Savings Areas underneath each of those areas will be a number pulled in from the external database.

Help! ??? :(

Thanks
Kenny


Top
 Profile  
 
PostPosted: Tue Nov 29, 2011 8:44 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Sun Feb 19, 2006 6:47 pm
Posts: 17933
Location: Toledo, OH
It may be simpler to do it with Fabrik... OR to import the table into the Joomla database.

_________________
Don't HACK the Joomla! core. Extend and Override.
http://harpervance.com -
Live Joomla! Help available at the site M-F, 9-12 am edt 2-5pm edt.
by appointment on evenings and weekends.


Top
 Profile  
 
PostPosted: Tue Nov 29, 2011 9:10 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Nov 29, 2011 8:22 pm
Posts: 43
Hi ranwilli -

I guess I'll have to Google what Fabrik is. The client is using another custom coded admin section from an external website outside of Joomla to dynamically update the information. So not sure I want to mess with that system so I was really just trying to connect to what the client already has setup. If I copied the info from the external database over to the Joomla database wouldn't that external admin need updated as well? Again, I'm a newbie when it comes to database and querying.

I was told that the code to display the numbers is done this way:

The code that calls the SQL stored procedure and then populates is right at the beginning of the "insurance.aspx.vb" file. (that code basically just fills numbers into the placeholders in the DIV's)

Any other suggestions or advise?

Thanks!


Top
 Profile  
 
PostPosted: Wed Nov 30, 2011 7:08 pm 
Joomla! Master
Joomla! Master

Joined: Mon Oct 27, 2008 9:27 pm
Posts: 18294
Location: Akershus, Norway
So the data is stored in MS SQL Server.

The web server must have the MS SQL Server client installed in php.

Use the php library for MS SQL Server to access that database.

http://no.php.net/manual/en/book.mssql.php


Top
 Profile  
 
PostPosted: Wed Nov 30, 2011 7:25 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Nov 29, 2011 8:22 pm
Posts: 43
Hi Per Yngve Berg-

Yes the data I need to showcase on the web page is stored in an MS SQL server. So a query needs assembled using the PHP execute ms sql function, right?

Here is the code that my colleague came up with does it look right? If it does, then how do I implement into Joomla 1.7? In other words, what code goes in the index.php file and how do the files work together such as the file structure for implementing such code??

Here's the documentation page:
http://php.net/manual/en/function.mssql-execute.php

/* Total Statistics Query */

<?php
$host = my_ip_address
$user = myusername
$pass = mypassword
$database = mydatabase
$conn = mssql_connect($host, $user, $pass);
mssql_select_db($database, $conn);

$stmt = mssql_init('usp_getsavingsinfo');
$result = mssql_execute($stmt);
mssql_free_statement($stmt);
?>

Thanks for everyone's help so far. So glad I posted my question!


Top
 Profile  
 
PostPosted: Wed Nov 30, 2011 7:32 pm 
Joomla! Master
Joomla! Master

Joined: Mon Oct 27, 2008 9:27 pm
Posts: 18294
Location: Akershus, Norway
http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1


Top
 Profile  
 
PostPosted: Wed Nov 30, 2011 7:50 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Nov 29, 2011 8:22 pm
Posts: 43
Per Yngve Berg -

Thanks for the link so I guess I need to create a custom component within Joomla then assign the new component to the area of my home page where I want it to display, right?

Looks kinda intricate but I will try and follow the steps from the link you supplied in order to get my data from the MS SQL server to display on the page dynamically.

Any other feedback before I begin? I scanned over the link you provided it seems as though close attention needs to be followed when setting up the file structuring.

Thanks again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 



Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group