Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Conclusion

June 30, 2000

Unlike check, have_perm returns true or false, and does not exit the script. You can use this for conditional testing, such as:


<?php

if ($perm->have_perm("guest")) {
    //do something;
} elseif ($perm->have_perm("admin")) {
    //do something else;
} else {
    //yet something else;

}

?>

Database Abstraction

As mentioned earlier, PHPLIB uses a database abstraction layer. This is required for use with the other classes (authentication, session), but is also extremely handy to use on your own. It allows you to use a set of arbitrary database commands which will then be mapped to the database you are using. The benefit of this is that your apps can work with any database simply by changing your local configuration. Here's a simple example to query a database.


<?php

$db = new DB_MyDBClass;
$query = "select name from sometable";
$db->query($query);
while ($db->next_record()) {

$db->p("name");
}

?>

The first line creates a new database object. The username, password, host, and database are set in your local configuration. The third line then queries the database, and stores the result set in the database object. The $db->next_record() advances result set to the next row. The $db->p("name") prints out the value of the field name. You can also say $db->f("name") which simply returns the value rather than printing it out. The above is equivalent to this chunk of mysql specific code, and also automatically provides error handling and centralized storage of connection data:


<?php

mysql_connect("localhost","username","password");
mysql_select_db("some_db");
$query = "select name from sometable";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
    $row["name"];
}

?>

Conclusion

There is a lot more to what PHPLIB can do, this is just an introduction. There are more functions and classes you'll want to look at, so head over to http://phplib.netuse.de and check out the docs. Check out the showroom to get an idea of how to put together a system.

--Chad

Register the Variable
Session Management and Authentication with PHPLIB


Up to => Home / Authoring / Languages / PHP / Session_Management




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers