CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Global use of connection parameters

Print topic Send  topic

Author Message
headhunter


Posts: 130
Posted: 08/10/2007, 2:04 PM

Is it possible to use the connection parameters that are prepared in Common.php through the whole project? (Like database password, login, etc....). I need this because I use some php classes that require database connectivity, which are mostly set up with own connection parameters which I want to pass from the CCS project settings. otherwise I have to modify the class file to use the CCS db connection, or must manualy change the parameters for the connection.

I have already tried some things but they didn't work...
View profile  Send private message
DonP
Posted: 08/10/2007, 2:40 PM

I have a third-party DHTML menu that uses the CCS connection and functions,
which is done by including the menu object into the project. The menu is
JavaScript but uses PHP/CCS programming embedded into it to get the items
from the database. For other PHP functions that need to be available
site-wide, I always include them at the bottom of Common.php. Is this the
type of thing you are trying to do?

"headhunter" <headhunter@forum.codecharge> wrote in message
news:546bcd2e82a530@news.codecharge.com...
> Is it possible to use the connection parameters that are prepared in
> Common.php
> through the whole project? (Like database password, login, etc....). I
> need this
> because I use some php classes that require database connectivity, which
> are
> mostly set up with own connection parameters which I want to pass from the
> CCS
> project settings. otherwise I have to modify the class file to use the CCS
> db
> connection, or must manualy change the parameters for the connection.
>
> I have already tried some things but they didn't work...
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>

headhunter


Posts: 130
Posted: 08/11/2007, 12:22 AM

Not exactly, I also do something similar for other functions etc.
But I want to use as much as possible build-in features from ccs to have consistent code. Otherwise I have to additionally define all these parameters again and they already exist.

Look in Common.php for this connection settings "$CCConnectionSettings = array (...." and connection class "class clsDBcms extends DB_MySQL....."

There must be a way to re-use these, but I don't know how.
View profile  Send private message
DonB
Posted: 08/11/2007, 6:02 AM

If you include Common.php into your non-CCS code, then you certainly could
create connections with

$conn = new clsDBcms

and utilize $conn->link_id() as the 'connection' parameter of any code that
utilizes the MySQL functions in PHP.

Or you could simply 'global' the $CCConnectionSettings variable and
reference the values it contains to create connections in the non-CCS code.

You'll have to figure out the correct value for, and then define,
'RelativePath' in your non-CCS code so that you are successful with
include-ing Common.php.
--
DonB

http://www.gotodon.com/ccbth


"headhunter" <headhunter@forum.codecharge> wrote in message
news:546bd63b311e90@news.codecharge.com...
> Not exactly, I also do something similar for other functions etc.
> But I want to use as much as possible build-in features from ccs to have
> consistent code. Otherwise I have to additionally define all these
parameters
> again and they already exist.
>
> Look in Common.php for this connection settings "$CCConnectionSettings =
array
> (...." and connection class "class clsDBcms extends DB_MySQL....."
>
> There must be a way to re-use these, but I don't know how.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

headhunter


Posts: 130
Posted: 08/11/2007, 1:47 PM

DonB, DonP,

Thanks for any help.

I use it now in an include page for displaying user's geographical location (country). I use the IpToCountry class for this.

I came up with the following code and it works now:
BTW, you can test it on my test site if it works: There should be a country origin and flag on the right top of the right navigation of the site at:

http://headhunter.dnsalias.org:2080/~freestyle/Store/index.php?front_id=17

BTW2: I still use Vision.to's CMS BE as my development base :-)

In before show event of the page:

  
global $CCConnectionSettings;  
$Configuration = $CCConnectionSettings["cms"];  
  
require_once("../Extra/class.ip2country.php");  
  
$ip = $_SERVER["REMOTE_ADDR"];  
  
$iplook = new ip2country($ip);  
  
$iplook->UseDB			= "true";  
$iplook->db_login		= $Configuration["User"];  
$iplook->db_password	= $Configuration["Password"];  
$iplook->db_basename	= $Configuration["Database"];  
$iplook->db_tablename	= "cms_iptocountry";  
$iplook->db_prefix1_colname	= "country_code2";  
$iplook->db_prefix2_colname	= "country_code3";  
$iplook->db_country_colname = "country_name";  
  
if ($iplook->LookUp())  
	{  
		$Component->country_msg->SetValue( "You come from ".$iplook->Country);  
			if(file_exists(FLAGS_DIR."".strtolower($iplook->Prefix1).".gif"))  
				{	  
					$Component->flag->SetValue(VISION_TO_EMBED_IMAGE(FLAGS_DIR."".strtolower($iplook->Prefix1).".gif",strtolower($iplook->Prefix1).".gif"));  
				}  
			else  
				{  
					$Component->flag->SetValue("");  
				}  
	}  
else   
	{  
		$Component->country_msg->SetValue( "Don't know where you are from.");  
	}  
View profile  Send private message
wkempees
Posted: 08/12/2007, 4:31 AM

Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in
/home/freestyle/public_html/Functions/cms_func.php on line 671


Flag is red/white/blue which is indeed Nederlands!
Site speeks nederlands to me too (Vlaams?), bt then it does always.
;-)

Walter

"headhunter" <headhunter@forum.codecharge> schreef in bericht
news:546be206c83126@news.codecharge.com...
> DonB, DonP,
>
> Thanks for any help.
>
> I use it now in an include page for displaying user's geographical
> location
> (country). I use the IpToCountry class for this.
>
> I came up with the following code and it works now:
> BTW, you can test it on my test site if it works: There should be a
> country
> origin and flag on the right top of the right navigation of the site at:
>
> http://headhunter.dnsalias.org:2080/~freestyle/Store/index.php?front_id=17
>
> BTW2: I still use Vision.to's CMS BE as my development base :-)
>
>
  
> global $CCConnectionSettings;  
> $Configuration = $CCConnectionSettings["cms"];  
>  
> require_once("../Extra/class.ip2country.php");  
>  
> $ip = $_SERVER["REMOTE_ADDR"];  
>  
> $iplook = new ip2country($ip);  
>  
> $iplook->UseDB = "true";  
> $iplook->db_login = $Configuration["User"];  
> $iplook->db_password = $Configuration["Password"];  
> $iplook->db_basename = $Configuration["Database"];  
> $iplook->db_tablename = "cms_iptocountry";  
> $iplook->db_prefix1_colname = "country_code2";  
> $iplook->db_prefix2_colname = "country_code3";  
> $iplook->db_country_colname = "country_name";  
>  
> if ($iplook->LookUp())  
> {  
> $Component->country_msg->SetValue( "You come from ".$iplook->Country);  
> if(file_exists(FLAGS_DIR."".strtolower($iplook->Prefix1).".gif"))  
> {  
> $Component->flag->SetValue(VISION_TO_EMBED_IMAGE(FLAGS_DIR."".strtolower($iplook->Prefix1).".gif",strtolower($iplook->Prefix1).".gif"));  
> }  
> else  
> {  
> $Component->flag->SetValue("");  
> }  
> }  
> else  
> {  
> $Component->country_msg->SetValue( "Don't know where you are from.");  
> }  
> 
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>

headhunter


Posts: 130
Posted: 08/12/2007, 2:03 PM

Hi Walter,

I don't get the HTTP_ACCEPT_LANGUAGE error. When do you get this error?
And indeed, site is Nederlands (dutch) only. The site is not fully localised yet.

The country flags on top is to change the VAT (taxes, BTW...) for that country, not to change the language.

And hey, this is a test site :-P

I will use the Ip_to_country thingy to "guess" the visitors location and display the correct taxes for his country if this mode is active. My shop will have 3 modes: EU country, visitors origin or store origin for tax calculations.

Nice to have a northern neighbour on the forum (I'm from Belgium)...
View profile  Send private message
Wkempees
Posted: 08/12/2007, 2:48 PM

Fixed, error no longer appearing.
Good! It was displayed through the top banner.
You also made some other changes, specially language, now in English
(partly).

Have a Stella or a Palm on me, Rotterdam area
Walter

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.