...

View Full Version : Pear DB_DataObject questions.



Majoracle
01-20-2008, 02:19 PM
OK, I'm in the process of learning AJAX from a book called "Ajax in Action" and it's really big on making applications as simple and flexible as humanly possible. It mentions something cool called "Pear DB_DataObject (http://pear.php.net/package/DB_DataObject/)", an Object-Relational Mapping (ORM) tool which supposedly eliminates the need for messy SQL syntaxes by using objects (classes). You can extend it to your classes and it (from what I'm guessing), builds queries based on variables you set in a class. So like:


require_once "db/DB_DataObject.php";
class Item extends DB_DataObject
{
var $id;
var $name;
var $description;
/* ...and so on. */
}

OK, so my questions are:

- First, am I right about how this all works? I hope so, because it seems incredibly useful. The book I have doesn't explain it past mentioning it's usefulness (can't blame it, after all it's a book on AJAX, not PHP).

- It seems to use blank functions like find() as the "search", fetch() as the "mysql_fetch_array()", and clone() (which I have no idea).. Is there something that shows a list of the DB_DataObject functions and how to use them, or someone who knows? I tried looking on the Pear site and the downloaded scripts themselves, but couldn't find anything.

This and any information people maybe willing to offer about this DB_DataObject tool would be greatly appreciated. Thanks.

GJay
01-20-2008, 02:47 PM
I've never used that particular class, but ORM in general is really useful with more complicated applications.

It's maybe also worth pointing out that the author of that book (which is indeed really good) is one of the moderators on this board, in the javascript forums I believe, going under the nick 'Alien51' (the book is mentioned in his signature...), so maybe worth asking him if he has any useful links :)

Majoracle
01-21-2008, 01:39 AM
Oh wow, how often do you get the chance to consult the author of the book when you need help with something in it? Thanks for letting me know one of them actually posts here.

A1ien51
01-21-2008, 05:49 AM
Well I did not write the php sections since I am a .net guy.

Did you look at the api on the site: http://pear.php.net/package/DB_QueryTool/docs/latest/DB_QueryTool/DB_QueryTool.html

I will ask the other author if he knows any good resources on it other than the website.

Eric

Majoracle
01-22-2008, 09:45 AM
OK, yeah, I think I found list of them on that page: http://pear.php.net/package/DB_QueryTool/docs/latest/elementindex.html

I'll look over them (seems like a lot), but in the mean time, just use PHP's built in functions. Thanks Eric.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum