What is Pear DB library? - php

I am a noob to PHP can anyone explain me whats Pear DB library with a practical use?
Thanks

http://pear.php.net - PEAR is a framework and distribution system for reusable PHP components.
EDIT(to the first answer):
Except DB abstraction packeges PEAR library contains huge amount of useful classes for work with XML, CURL etc. Full list of maintained packeges is available here.
BTW, PEAR stands for PHP Extension and Application Repository

The What:
Pear DB is abstraction layer. Its one of many framework components available from PEAR. What the heck is that? Its a layer/interface between PHP and the db provider (MySQL, MSSQL,Protege) . So, it handles calls to multiple types of db providers in pretty much the same way to your PHP application. Your application layer doesn't have to concern itself with the details of calling individual providers.
Pros:
Portability. Allows you to write your db interface code once and have it work with multiple providers.
Encapsulation. Makes many db calls a bit simpler to make.
Cons:
Performance. It will generally be a bit slower than calling php db commands directly.
Nutshell:
Its good to use it when you can.

Its just a database abstraction library. ALlows you to connect to different kinds of databases (MySQL, PostgreSQL) using a consistent API.

Related

Database abstraction options for hosts that disallow installation of PEAR modules

A prospective host disallows PEAR modules except for VPS/dedicated accounts. Can't afford spending $2000-3000/yr on VPS on a hobby site, so that option is out.
I'd like to add some database abstraction and recoded most of my site locally with MDB2 before running into issues with my current host (stacked server, old hardware, sluggish performance).
Are there options for implementing DB abstraction without a native PEAR module?
Are there options for implementing DB abstraction without a native PEAR module?
PECL modules require compilation and installation, thus sysadmin intervention.
PEAR modules are pure-PHP. You can simply grab the tar files from http://pear.php.net/ , extract them, and push the contents wherever they are needed. Assuming that the module(s) that you need have sane licensing, you can even bundle them with your existing source code.
That said, you should not be using PEAR's MDB2 in this day and age. Use PDO. It's PHP native and does most of the things MDB2 did, only without the suck. The convenience methods are easy to add through simple inheritance. If you actually need an SQL builder, the one included with Zend Framework (Zend Db Select) isn't too shabby.

Secure user authentication frameworks, libraries

I know this question has been asked more then once and more then twice but most answeres i've found here haven't helped me at all.
Since i started to code i've used three selfmade different authentication implementations based on cookies. I've never took much stand against injection or hijacking but this time i am trying to incorporate that in both my user authentiaction and submitting forms.
Since there are thousands of user authentication scripts to choose from i want to ask what frameworks or scripts you would recommend i use? I've tried a few but no one has really done the job? I'm not useing any php framework like Zend, Codeigniter or similar.
I plan on using SSL as well but on some sites my cms will be used on will not have SSL.
Try this one: http://ulogin.sourceforge.net/
If you need an authentication library that ...
isn't tied to a single framework and
works with multiple database systems (e.g. MySQL, PostgreSQL, SQLite, etc.)
... then https://github.com/delight-im/PHP-Auth might be for you.
It's modern (PHP 5.6+), secure and convenient.
Symfony2 provides a security component that is available as a standalone PHP library.
Documentation: Symfony2 - Security
Download it from GitHub

CakePHP, CodeIgniter and FuelPHP - which do you prefer and why?

I've been looking into learning a PHP framework lately and have spotted these three popular choices. They all seem to have similar approaches and methods, and I'm not sure where to begin. If you are or have been using either one I'd greatly appreciate any pros, cons or other info you might want to share about them.
I'm considering these frameworks with the following in mind:
- Which one has best multi-lingual support?
- Which is the easiest to implement / start out with?
- Which is the most future-proof and versatile (i.e. working with NoSQL databases such as MongoDB)?
I have been using all of the mentioned frameworks, but I really enjoy using the codeigniter framework, because it is very lightweight and does not interfere with my workflow in doing too much things I don't want.
The i18n and multi-lingual support is really simple, there is a helper and a class ready to use.
Codeigniter has also pretty much support for any database you may want to use. If you happen to use a database that isn't supported, you can easily write your own database driver, just take a look at one of the driver files.
It is also very easy to integrate other external libraries e.g. Doctrine, adodb into your project.

PHP ORM with NOSQL and RDBMS support

Are there any PHP ORM projects which supports MySQL and NoSQL databases such as MongoDB?
I am currently using RedBean to do MySQL ORM, however I woud like to introduce MongoDB to the applicatoin and perhaps even replace some of the MySQL with MongoDB in the future.
An ORM that can allow me to easily transition between both would be nice. However, I tend to not like ORM that requires too much configuration (i.e. YAML, XML etc). RedBean is very nice in that it allows one to easily get things working without too much configuration.
Yes, doctrine supports various RDBMS and NoSQL storages as well
Docrine 2 contains both an ORM and ODM for NoSQL databases (MongoDB and CouchDB are supported), and its theoretically possible to hook up Doctrine to anything else.
We're working on some adapter-based ORM called UniMapper in our company.
It provides a uniform API for accessing stuff from different kinds of databases, protocols, and 3rd party APIs. You can even associate between entities from different storages. And it should be even faster than Doctrine. Try it give us some feedback :-).
MongoDB will be supported very soon, but you can write extension on your own, it's very easy.
However the quick start is not complete, you can ask me or somebody from our team.

Zend Framework EAV Implementation

I was wondering if there were any good pre-built ways to implement an EAV design pattern in Zend Framework?
I am trying to decide if I should create my own implementation or use one that has already been built.
Use Doctrine with MongoDB Document Mapper http://www.doctrine-project.org/
Zend Framework 2.0 has automated install for Doctrine with Composer, so it means Zend People also offer this as an Option apart from the built-in Zend_Db.
Using EAV on a document-oriented NoSQL database system like MongoDB or CouchDB is way much better than implementing a Hack over Traditional Relational Databases like MySql ( something that Magento did ). NoSQL Databases are better at implementing Sparse Matrix type Data.
Check out Zend Framework EAV on Google Code.
Digitalus CMS uses the EAV pattern, and is based on MySQL. It is true that Mongo or Couch might be more appropriate, but MySQL is often an easier choice because you don't have to install anything. I have tried using SimpleDB, but the local MySQL version is 4x faster. SQLite also works very well.
There are a lot of opponents to this approach, and their claims are largely founded. Any time I need to be able to query data I use a standard relational approach, but EAV shines when you are working with very loosely structured data like the content on a web page.
Digitalus uses an approach where there is the base CMS item model that handles all of the EAV logic. This model also handles a write-through cache so the system ultimately serves content as fast as a flat file system.
All the purists are probably technically correct, but fast and easy have a place in my toolbox.

Categories