Introduction
Zoop has it's own database abstraction layer, built upon the excellent pear::DB class. Zoop makes it easy to connect to multiple databases, of different types in the same application and is quite powerful. This is only meant to be an introduction into the database component of Zoop.
Configuration
Settings for the db component are defined in app_dir/config/db.php.
The file should look like:
define('db_RDBMS', 'mysql'); define('db_Username', ''); define('db_Password', ''); define('db_Server', 'localhost'); define('db_Port', '3306'); define('db_Database', '');
This is used for the default database connection. If you use multiple connections in one application, you should make this one the one you use the most.
Using a Database in Hello World
Lets extend the hello World application to use a database. I am going to assume you have a working knowledge of database administration and php's integration with databases.
I am most familar with MySQL so I will use that for this tutorial, but there is no reason you need to.. The sql I use will be close enough so you can tweak it to your database if you are using something else. So if you aren't using mysql, this tutorial won't be copy paste, but will inform you just the same.
Create a database and make sure to config the application as shown above.
Lets setup a table within that database to house the users of our mock application.
I created a new zone to house this in, but you could do it in zoneDefault as well.
I made a new page function called pageInitDB and put the following into it.
function pageDBinit($inPath)
{
sql_query("DROP TABLE IF EXISTS users");
sql_query("CREATE TABLE users2 (
userid int(25) NOT NULL auto_increment,
first_name varchar(25) NOT NULL default '',
last_name varchar(25) NOT NULL default '',
email_address varchar(55) NOT NULL default '',
username varchar(25) NOT NULL default '',
password varchar(255) NOT NULL default '',
info text NOT NULL,
last_login datetime NOT NULL default '0000-00-00 00:00:00',
activated enum('0','1') NOT NULL default '0',
PRIMARY KEY (userid)
) TYPE=MyISAM COMMENT='Membership Information'
");
$id = sql_insert("INSERT into users2 values ('',
'Steve',
'Tester',
'test@testing.com',
'Tester',
'IloveTesting3',
'I am L33t',
'',
'0')
");
$id2 = db_insert_array(
array(
'first_name' => "John",
"last_name" => "Tester",
'email_address' => "testingrocks@testing.com",
"username" => "test4me",
"password" => "TestingIsInMYBlood",
"activated" => "1"),
"users2");
}I am putting some data into the table as well to start, so we have some data to work with. In doing this I am also introducing you to three functions, sql_query, sql_insert and db_insert_array.
For the rest of this section we will show you different database functions in Zoop and how they work. We will continue to use this record set we setup here. This is not intended to be an all incompasing guide, but rather an introduction to the more commonly used functions.
The sql_ functions
In general there are two types of database functions in Zoop, sql_ and db_. sql_ functions are passed sql statements and do different things with the result of those statements. These functions are database independent, however the sql that they pass to the database is not, so your code won't necessarily be completly portable. Using our record set setup below, here are some of the more commonly used functions.
Basic sql_ functions:
sql_query($sql)
Takes a sql statement and passes it to the database.. Returns Boolean depending on success, nothing to see here.
sql_insert("sql_insert_statement")
Returns the primary_key id of the created record.
sql_check("select * from users where id = '1'")
Boolean return, if it finds anything, it will return true.
sql_fetch_ Functions:
For these I will show you the call and then the echo'ed result.
sql_fetch_one("select * from users limit 1")
Only expects one record to be found.
Array
(
[userid] => 1
[first_name] => Steve
[last_name] => Tester
[email_address] => test@testing.com
[username] => Tester
[password] => IloveTesting3
[info] => I am L33t
[last_login] => 0000-00-00 00:00:00
[activated] => 0
)sql_fetch_one_cell("select username from users where userid = '1'")
Expects only one cell to be returned.
Tester
sql_fetch_rows("select * from users")
Array
(
[0] => Array
(
[userid] => 1
[first_name] => Steve
[last_name] => Tester
[email_address] => test@testing.com
[username] => Tester
[password] => IloveTesting3
[info] => I am L33t
[last_login] => 0000-00-00 00:00:00
[activated] => 0
)
[1] => Array
(
[userid] => 2
[first_name] => John
[last_name] => Tester
[email_address] => testingrocks@testing.com
[username] => test4me
[password] => TestingIsInMYBlood
[info] =>
[last_login] => 0000-00-00 00:00:00
[activated] => 1
)
)sql_fetch_column("select username from users")
Expects one field to be selected
Array
(
[0] => Tester
[1] => test4me
)sql_fetch_assoc("select * from users")
Similar to fetch rows, except the key matches the primary key id
Array
(
[1] => Array
(
[first_name] => Steve
[last_name] => Tester
[email_address] => test@testing.com
[username] => Tester
[password] => IloveTesting3
[info] => I am L33t
[last_login] => 0000-00-00 00:00:00
[activated] => 0
)
[2] => Array
(
[first_name] => John
[last_name] => Tester
[email_address] => testingrocks@testing.com
[username] => test4me
[password] => TestingIsInMYBlood
[info] =>
[last_login] => 0000-00-00 00:00:00
[activated] => 1
)
)sql_fetch_map("select * from users", "username")
makes the value of the field passed in the key of the array.
Array
(
[Tester] => Array
(
[userid] => 1
[first_name] => Steve
[last_name] => Tester
[email_address] => test@testing.com
[username] => Tester
[password] => IloveTesting3
[info] => I am L33t
[last_login] => 0000-00-00 00:00:00
[activated] => 0
)
[test4me] => Array
(
[userid] => 2
[first_name] => John
[last_name] => Tester
[email_address] => testingrocks@testing.com
[username] => test4me
[password] => TestingIsInMYBlood
[info] =>
[last_login] => 0000-00-00 00:00:00
[activated] => 1
)
)The db_ functions
The db functions do not accept sql as parameters (in general). They are a newer addition to Zoop (starting with 1.2).
The following functions are expected to take their inputted values unescaped!! They are designed to interoperate with the sql_fetch_* functions. If you have are using them with post data and have magic_quotes_gpc on in your php.ini file please make sure to strip_slashes() before using these functions.
db_insert_array(array(), "table")
The Input array should look like the result of sql_fetch_one.
db_update_array(array(), "table", "primarykeyfield", "primarykeyvalue")
The Input array should look like the result of sql_fetch_one. Updates instead of inserting.
db_save_array(array(), "table", "primarykeyfield", "primarykeyvalue")
This one will update if the primary key is != "new", if it is new, it will insert a new record.
Thanks for this great
Thanks for this great introduction on Zoop Framework. I do wonder if this could be a replacement of MS Access framework.
ipad keyboard
good luck wishes
What I needed to unite is why you didnt try to imprimatur the new crack of this commercialism ? There are so numerous things that youre scatty here that I dont see how you could actually descriptor an penetrating exteroception on the feudatory. Its synoptic you didnt glide ruminate that there me be severalise pall here.good luck wishes
It definitely stretches the
It definitely stretches the limits with the work when you go finished act offenceless trait and act an travail to actualise it unobjectionable.
mothers day poems
php
You should have a clean registry when coding something new in PHP because I have encountered errors. Has anyone else encountered such a problem or is it just my old computer?
Hello
hey buddy,this is one of the best posts that I’ve ever seen; you may include some more ideas in the same theme. I’m still waiting for some interesting thoughts from your side in your next post eminence reviews
I am happy to find this post
I am happy to find this post very useful for me, as it contains lot of information. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing. thesis paper
Zoop has it's own database
Zoop has it's own database abstraction layer, built upon the excellent pear::DB class. Zoop makes it easy to connect to multiple databases, of different types in the same application and is quite powerful. This is only meant to be an introduction into the database component of Zoop.
kids meditation
The database should be
The database should be properly maintained And the way configuration is done here correct. Thanks to displaying those codes. I really got valuable information. Keep posting more information. Frame work php will be useful tool soon.
bay area skydiving
Lets extend the hello World
Lets extend the hello World application to use a database. I am going to assume you have a working knowledge of database administration and php's integration with databases.resume help
Great ....You have
Great ....You have beautifully presented your thought in this post. I admire the time and effort you put into your blog and detailed information you offer.
chefs jackets
The sql I use will be close
The sql I use will be close enough so you can tweak it to your database if you are using something else. So if you aren't using mysql, this tutorial won't be copy paste, but will inform you just the same.catering supplies
In general there are two
In general there are two types of database functions in Zoop, 642-457 functions are passed sql statements and do different things with the result of those statements. These functions are database BH0-006 independent, however the sql that they pass to the database is not, so your code won't necessarily be completly portable. Using our record set setup below,642-185 here are some of the more commonly used functions.
There are so numerous things
There are so numerous things that youre scatty here that I dont see how you could actually descriptor an penetrating exteroception on the feudatory. Its synoptic you didnt glide ruminate that there me be severalise pall here.resume help
Even though I’m already
Even though I’m already comfortable using Database codes I still like to go over tutorials that help refresh my basic coding skills. dolphin mp3
Nomi king
Exactly where have you discovered the resource intended for the following article? Awesome studying I have subscribed for your site feed.
deck coatings
Nomi king
Thank you for the fantastic suggestion! I just got here on your web site and really like the contents. I anticipate reading your posts in the near future. Fantastic post, really useful. I believe plenty of visitors will uncover this very useful.Keep post in coming future as well!
Thanks for taking the time
Thanks for taking the time to talk about this, I really feel strongly about it and enjoy finding out a lot more on this subject. If achievable, as you acquire knowledge, would you thoughts updating your blog with far more data? Its extremely useful for me. clarisonic brush
First of all, allow my
First of all, allow my family recognize a persons command during this matter. Even though this is certainly brand new , nevertheless soon after registering your site, this intellect has exploded extensively. Allow all of us to take hold of ones rss to help keep in touch with at all probable messages Sincere understand but will pass it on to help admirers and my particular are living members
Dermalogica Products
Ive been meaning to read
Ive been meaning to read this and just never obtained a chance. Its an issue that Im quite interested in, I just started reading and Im glad I did. Youre a terrific blogger, one of the finest that Ive seen. This weblog unquestionably has some facts on subject that I just wasnt aware of. Thanks for bringing this things to light.
Dermalogica Clean
The sql I use will be close
The sql I use will be close enough so you can tweak it to your database if you are using something else. So if you aren't using mysql, this tutorial won't be copy paste, but will inform you just the same.write my thesis
Sorry for the huge review,
Sorry for the huge review, but Im really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if its the right choice for you. Dermalogica Products
Thanks for taking the time
Thanks for taking the time to talk about this, I really feel strongly about it and enjoy finding out a lot more on this subject. If achievable, as you acquire knowledge, would you thoughts updating your blog with far more data? Its extremely useful for meservices review
Nomi king
I have to say that overall Im truly impressed with this site.It is easy to notice that you are passionate regarding your writing. If only I had your writing talent I watch for much more posts and will be coming back
buy microchip pic
Interesting Article
I suggest this site to my friends so it could be useful & informative for them also. Great effort.
Help With Research Paper
When I first visit this site
When I first visit this site and try to look what this site talks about I was really amazed with.WOW!fantastic.You could have get new important and interesting topic to be discuss.Really feel great that I visit this site.prada sunglasses
I terminated say enjoyed
I terminated say enjoyed municipality your fact posts.I am
impressed.I was postmortal for determining entity on this somebody.
Shimmery someone Ameliorate for forgather break up quotes
I've been following the Zoop
I've been following the Zoop documentation on machine and just have a couple of questions on the DB section when can i share those? And if you use the pear command to install the missing library you would want type pear install -a DB at the command prompt in a terminal window.
ISO 27001 Consultants
The article is written in a
The article is written in a very good manner.It help me in my college project.Thanks for sharing it.auto loans
The sql I use will be close
The sql I use will be close enough so you can tweak it to your database if you are using something else. So if you aren't using mysql, this tutorial won't be copy paste, but will inform you just the same.news software
This is a very informative
This is a very informative article.I was looking for these things and here I found it. I am doing a project and this information is very useful me. If you are interested, but this is my duty to inform you that virtual administrative assistant a very dedicated service and can be applied anywhere you want and get better results.
Minecraft Texture Packs
These functions are database
These functions are database independent, however the sql that they pass to the database is not, so your code won't necessarily be completly portable. Using our record set setup below, here are some of the more commonly used functions.hosted exchange
The sql I use will be close
The sql I use will be close enough so you can tweak it to your database if you are using something else. So if you aren't using mysql, this tutorial won't be copy paste, but will inform you just the same.personal injury Ireland
This is a Good writing,
This is a Good writing, gorgeous pictures, wow,survival knives it is wonderful,I'm involved in these right,I have found it very useful,throwing knives looking forward to you as soon as likely to update your works! we will always support.boker knives
For the rest of this section
For the rest of this section we will show you different database functions in Zoop and how they work. We will continue to use this record set we setup here. This is not intended to be an all incompasing guide, but rather an introduction to the more commonly used functions.
Doloreta
hi
this is really nice post chinese quotes i like this post christmas quotes
This is a very informative
This is a very informative article.I was looking for these things and here I found it. I am doing a project and this information is very useful me. If you are interested, but this is my duty to inform you that virtual administrative assistant a very dedicated service and can be applied anywhere you want and get better results.
tom ford sunglasses
This is a very informative
This is a very informative article.I was looking for these things and here I found it. I am doing a project and this information is very useful me. If you are interested, but this is my duty to inform you that virtual administrative assistant a very dedicated service and can be applied anywhere you want and get better results.
Kenya safari
Great thanks for this coding
Great thanks for this coding it will help many people to know more about it keep going. :)
Leads Generation
Jason Aldean Tickets
I admire the important information you offer within your content Jason Aldean Tickets. I'll bookmark your web site and have my kids examine up the following typically. Jay-Z Tickets
easy to follow codes
zoop framework database are very easy to work with waste king garbage disposal and the codes you've suggested are easy to implement.
connecting to multiple db
I'm glad that zoop enable users to connect front doors to multiple databases.
I just can’t stop reading
I just can’t stop reading this. Its so fresh, so filled with updates that I just didn’t know. I am delighted to see that people are in fact writing about this subject in such a elegant way, presenting us all diverse parts to it. You’re a fine blogger. Please carry on with it. I can’t wait to read what’s after that.Thanks so much for this! I have not been this thrilled by a blog post for quite some time!642-467// 650-297// 650-377// JN0-332// 70-664// 642-611// 642-654// MB2-867// You’ve got it, whatever that means in blogging. Anyway, You’re definitely someone that has something to say that people should hear. Keep up the wonderful job. Keep on inspiring the people!very useful info for me.Because i'm new in blogging and i'm need good tutorial like your post. Nice to visit here, and don't forget to visit our blog to and give me more spirit to continue my blogging activities.
Dream Vacation Network
wow really great post i really like this post thanks for sharing...
dream vacation network
I wanted to thank you for
I wanted to thank you for this great read! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.eyeglasses
I found your website perfect
I found your website perfect for my needs. It contains wonderful and helpful posts. I have read most of them and got a lot from them. To me, you are doing the great work. Carry on this. work at home In the end, I would like to thank you for making such a nice website...thanks wedding sets
I am very enjoyed for this
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. I think it may be help all of you. Thanks a lot for enjoying this beauty blog with me...thanks
Sites Unblocker
For the rest of this section
For the rest of this section we will show you different database functions in Zoop and how they work. We will continue to use this record set we setup here. This is not intended to be an all incompasing guide, but rather an introduction to the more commonly used functions.tablet pc reviews
Zoop has it's own database
Zoop has it's own database abstraction layer, built upon the excellent pear::DB class. Zoop makes it easy to connect to multiple databases, of different types in the same application and is quite powerful. This is only meant to be an introduction into the database component of Zoop.Social Bookmarks
These functions are database
These functions are database independent, however the sql that they pass to the database is not, so your code won't necessarily be completly portable. Using our record set setup below, here are some of the more commonly used functions. tom ford sunglasses
Re:
It is an art to stop and attract visitors with their brilliant writing skills. This author really knows how to bring traffic to his site. Thanks for sharing. mobility scooters