PHPillow: librería PHP para CouchDB

Iniciado por ANTRAX, Febrero 24, 2013, 09:38:35 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

PHPillow es una librería PHP que nos permite interactuar con CouchDB (base de datos documental de Apache basada en JSON).

Ahora que el NoSQL es una alternativa a las bases de datos relacionales, esta librería nos ayudará bastante a la hora de realizar nuestra aplicación, ya que el código es bastante sencillo.

Código: php
class myBlogDocument extends phpillowDocument { 
  protected static $type = 'blog_entry';
  protected $requiredProperties = array( 'title', 'text', );
  public function __construct() {
    $this->properties = array(
      'title' => new phpillowStringValidator(),
      'text' => new phpillowTextValidator(),
      'comments' => new phpillowDocumentArrayValidator( 'myBlogComments' )
    );
    parent::__construct();
  }
  protected function generateId() {
    return $this->stringToId( $this->storage->title );
  }
  protected function getType() {
    return self::$type;
  }
}