Act DEV
Act DEV

Reputation: 129

Xml database in PHP

I need to use xml as database in php. Till now i used mssql,mysql as database in php. Is it possible to do so?

Upvotes: 1

Views: 784

Answers (3)

matt
matt

Reputation: 16

Yes, actually in php5 this is very easy to implement. http://devzone.zend.com/article/1713 for example.

Upvotes: -2

Luke Berry
Luke Berry

Reputation: 1947

Of course it is, it depends how you want it laid out though.

Although, XML isn't technically a database.

If you were using a system that requires the use of user registration, you could have either an XML file per user, or an overall user XML file.

1 - User1.xml

<user>
    <username>User</username>
    <password>Pass</password>
</user>

2 - Users.xml

<user>
    <username>User1</username>
    <password>Pass</password>
</user>
<user>
    <username>User2</username>
    <password>Pass2</password>
</user>

These are some very simple methods that could be used.

Then in order to check if a user has logged in you would need to iterate through the nodes in the XML file(s) and check the details.

Upvotes: 0

Marc B
Marc B

Reputation: 360622

XML is not a database. It's simply a standardized method of marking up data. You can treat it as a database, but you don't want to. The overhead of maintaining an XML tree is massive, especially if you have a lot of data. XML is NOT efficient for fast/random/abitrary access, especially since you'd have to load/parse the whole XML tree for every "database query" you perform.

About the only thing you'd gain from this is portability, but whatever site you're building would run slower than Windows 7 on an abacus.

Upvotes: 3

Related Questions