Quick db_component example, plus misc magic

The db_component is a big part of zoop. For many applications, database calls are a large part the work being done. The db_component provides the interface to your data. You can either use the default connection and global functions, or make your own connections and use the methods from the database object. There are too many functions to document here(be sure to look at the documentation), but this is an example of how to set up multiple connections. It also shows a way to deal with miscellaneous functions that you may need throughout your application. Keep in mind that it's always a good idea to keep your sql calls inside objects that encapsulate your business objects/model. The next example may be dbobject, a helper for your database objects.

config.php:

define_once('db_RDBMS', 'pgsql');
define_once('db_Server', 'localhost');
define_once('db_Port', 5432);
define_once('db_Username', 'someuser');
define_once('db_Password', '');
define_once('db_Database', 'somedb');
 
define_once('other_RDBMS', 'pgsql');
define_once('other_Server', 'localhost');
define_once('other_Port', 5432);
define_once('other_Username', 'otheruser');
define_once('other_Password', '');
define_once('other_Database', 'otherdb');

includes.php:

$zoop->addComponent('db');
$zoop->addInclude('misc', app_dir . '/misc.php');

By creating misc as a class, and calling functions statically, you can get the added bonus of autoincludes in php5 for your global-style functions. Of course, you can rename misc the name of your application, and it's even cleaner.
misc.php:
class misc
{
	function &getOtherDb()
	{
		if(isset($GLOBALS['otherDB']))
			return $GLOBALS['otherDB'];
		$dsn = Database::makeDSN(other_RDBMS, other_Server, other_Port, other_Username, other_Password, other_Database);
		$GLOBALS['otherDB'] = &new database($dsn);
		return $GLOBALS['otherDB'];
	}
}

zone_default.php:

zone_default extends zone
{
	function pageDefault()
	{
		sql_query();
		sql_insert();
		sql_check();
		sql_fetch_*();
		sql_begin_transaction();
		sql_commit_transaction();
		sql_rollback_transaction();
		sql_escape_string();
		$db = &misc::getOtherDb();
		$db->*();
	}
}

Hello

Thanks for sharing!

dominicgaines 29 Jun 2008

Sometimes you will encounter

Sometimes you will encounter problems where risk does change as time passes, and the use of a single risk-adjusted discount rate will then get you into trouble. Because an option’s risk is continually changing, the certainty-equivalent method needs to be used. free ads |jobs|twin memory foam mattress

DaniGrey 03 May 2011

Wie ein Preisvergleich

Wie ein Preisvergleich funktioniert.

kammolp 27 Jun 2011

I do not intend to be

I do not intend to be negative, it's just, sometimes I feel that there is a business game that became the background of all this. Even so, it remains a good move.
interior design architect
architectural rendering services

BabarSari 22 Aug 2011

Golden

The ZOOP Framework seems like an interesting project. Given that the information on this page for setting up multiply connections is fairly straight forward, I think that I will have to go and visit the documentation right away. Things just got really interesting. Perhaps this will become my golden egg. Golden Retriever Information

coderfrenzy 27 Aug 2011

This is very excellent

This is very excellent article.I read your article and got a very nice information.I will trying to sharing this information some other people.so I need some more information.Please give some information as soon as possible. French drain basement

mikael0820 29 Aug 2011

This is an online book in

This is an online book in that it is intended to be read in order. as each chapter builds on the chapters before it. It is also a handy reference when you want to know how to do something.
BDSM DVDs

devil 07 Dec 2011

non surgical face lift Adelaide

This is really stunning work.Thanks for this kind of stuff. I wanna say I am totally impressed.Hope to see some more update work here. I have to say it is quite informative.

http://www.tighter-skin-adelaide.com.au/

glenn17 09 Dec 2011

I have read the article

I have read the article fully. It helped me very much. I am a regular visitor of this site. Thanks for this great article. Keep it up dude.relatiegeschenken

leonardod 09 Jan 2012

This is a really good read

This is a really good read for me. Must agree that you are one of the coolest blogger I ever saw. Computerhulp

leonardod 15 Jan 2012

Nice post keep up with this

Nice post keep up with this interesting work. It really is good to know that this topic is being covered also on this web site so thanks for taking time to discuss this! panasonic 42 inch tv

flashwd 01 Sep 2011

The high waisted wide legged

The high waisted wide legged tight cuffed pegged trousers and a long coat with wide lapels and wide padded shoulders. Thanks for sharing the informative post. Regards. Umbrella Company

samson77 24 Sep 2011

This is a very intriguing

This is a very intriguing post, I was looking for this knowledge. Just so you know I found your web site when I was searching for blogs like mine, so please check out my site sometime and leave me a comment to let me know what you think. toshiba canvio plus 1 tb

flashwd 01 Sep 2011

DW Graph Component is a

DW Graph Component is a Joomla 1.5 native component for displaying graphs. With this component you can input numerical values with the help of CSV file and can show graphical representation of the input data in the site frontend.
Thanks
blog commenting

JerryS 01 Sep 2011

thank you, please visit Nike

thank you, please visit Nike free run 2

zoop110 04 Oct 2011

Posting from a Building site

Posting from a Building site - I'm into open cart framework and shifting into this framework might be too easy for me. Their syntax looks alike and this is also a good chance I discovered this framework for me to be a multilingual developer.

cristy 03 Nov 2011

I am from brand domains and

I am from brand domains and it seems that you are a multilingual guy. It looks like that it is and easy job for you shifting from thing you used to do and then to a new thing. Good for you dude. Cheers.

hinders 24 Jan 2012

nice

A very nice post, thank you for this article as I learn something interesting regnskap namsos

james0021 04 Nov 2011

Exactly, you're very kind of

Exactly, you're very kind of us about comment!
unlock iphone 4s

prince11 07 Dec 2011

Must concede that you are

Must concede that you are one of the best blogger I ever found. Thanks for posting this informative article. Find Sex

xec331 25 Jan 2012

nice

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog, I will keep visiting this blog very often.
moulin a vendre

cindycheng 30 Jul 2011

I enjoyed reading your easy

I enjoyed reading your easy transformations. I see you offer priceless info. Stumbled into this page by chance but I’m sure glad I clicked on that link.

wedding photography Sydney

danleyvilla 18 Aug 2011

This is a really good read for me.

This is a really good read for me. Must admit that you are one of the best bloggers I have ever read. Thanks for posting this informative article.

WHMCS License

laserlight 31 Jul 2011

Eine Autoversicherung

Eine Autoversicherung abschliessen.
Wie ein KFZ Versicherungsvergleich funktioniert.

Eine private Krankenkasse wechseln.
Wie die Private Unfallversicherung verglichen wird.
Den rechner private Krankenversicherung testen.

kamrioo 09 Aug 2011

Thanks for the wonderful

Thanks for the wonderful post. I will be sure to add your blog to my newsreader to keep up with your future Alaska Fishing Lodge posts. Being in the consulting business, it's fun to view things from a competing viewpoint.

vijaysbhagat 16 Aug 2011

Austin Home Builder

Add you for the owed airman. This job is handwritten in a really righteous collection. It helps me in many projects to tally. Thanks alot for relation it.Austin Home Builder

Lucky127 14 Jan 2012

This is a great inspiring article.

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information...

Accelerated Nursing Programs

laserlight 11 Aug 2011

Great Information sharing ..

Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post.

Baltimore SEO

laserlight 16 Aug 2011

I recently found many useful

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.

Cooking Games

laserlight 21 Aug 2011

thanks for this post

Thanks for this post, it's really as useful as Ultrasound Technician Salary. I like the information regarding the way to deal with miscellaneous functions that you may need throughout your application.

tintin2011 26 Aug 2011

Your website is really cool

Your website is really cool and this is a great inspiring article. Thank you so much.

Car Stereo

laserlight 03 Sep 2011

Thanks for posting this

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts...
American DJ

laserlight 04 Sep 2011

Childrens wholesale clothes

The information and the aspect were just wonderful. I think that your viewpoint is deep, it’s just well thought out and truly incredible to see someone who knows how to put these Childrens wholesale clothes

sohaib2649 01 Jan 2012

Good example of dp

Good example of dp component.i will this coding in my project.
Bollywood Movies

walter1 14 Sep 2011

thank good

Thanks a lot.I like this post,And I guess that they
having fun to read this post,they shall take a good site to make a
information,thanks for sharing it to me.
tabulos telefon wichsen

tabulos telefon... 15 Sep 2011

Thanks for taking the time

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.

Reading Glasses

simsim 04 Oct 2011

Its a great pleasure reading

Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work...

Reading Glasses

simsim 04 Oct 2011

This is very educational

This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post!

The Definition of Love

simsim 05 Oct 2011

I think that thanks for the

I think that thanks for the valuable information and insights you have so provided here.
Panic Attacks Treatment

jazzbee 03 Dec 2011

yacht charter Caribbean

I just wasnt aware of. Thank you for bringing more information to this topic for me. Im truly grateful and really impressed. yacht charter Caribbean

sohaib2649 21 Dec 2011

This blog is really great.

This blog is really great. The information here will surely be of some help to me. Thanks! find hosting

superpower 01 Jan 2012

Your website is really cool

Your website is really cool and this is a great inspiring article. Your website is really cool and this is a great inspiring article.

superking 01 Feb 2012

Your website is really cool

Your website is really cool and this is a great inspiring article. mobile anime streaming

superking 01 Feb 2012

Typo

This line in the function 'getOtherDb' above:

$dsn = Database::makeDSN(other_RDBMS, other_Server, other_Port, other_Username, other_Password, other_Database);

Specifically it should be other_Server and not other_Host and capitalization of other parameters should be corrected.

Jayesh Wadhwani

jwadhwani 18 Jun 2009

thanks

thanks for catching my typos. Fixed!

john 04 Aug 2009

http://www.seosoftwareservice

ssstechnology2 02 Jun 2011

Thanks for taking the time

Thanks for taking the time to discuss this, I feel strongly about information and love djstools learning more on this. If possible, as you gain expertise, It is extremely helpful for me. would you mind updating your blog with more information?

vijaysbhagat 02 Aug 2011

nice

This is one of the really nice info you have shared about the PHP.I am in need of some program of database with PHP and sql queries.Will you please help me for the same?
Web Design York

mattewking@hotm... 02 May 2011

Trowels

star09 11 May 2011

I also enjoy reading the

I also enjoy reading the comments, but notice that a lot of people should stay on topic to try and add value to the original blog post. I would also encourage everyone to bookmark this page to your favorite service to help spread the word Banner Design

kevinmiller 16 Mar 2011