• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Mongo + php
 

Mongo + php

on

  • 1,686 views

 

Statistics

Views

Total Views
1,686
Views on SlideShare
1,686
Embed Views
0

Actions

Likes
1
Downloads
11
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Mongo + php Mongo + php Presentation Transcript

    • MongoDB + PHP
    • QuemAgripino Duarte@agripinoduarte @RadigTI
    • MongoDb“MongoDB (from "humongous") is a scalable, high­performance,  open source NoSQL database” mongodb.org 
    • MongoDb✔  Escrito em C++✔  Linguagem Rica e de Fácil Entendimento✔  Orientado a Documentos (BSON)✔  Não Relacional (NoSQL)✔  Tipado Dinamicamente (Schemaless)✔  Suporte a Índices✔  Suporte a Replicação (Master­Slave e Replica Sets)✔  Map/Reduce✔  Mais...
    • MongoDbDrivers✔  C✔  C++✔  Erlang✔  Haskell✔  Java✔  Javascript✔ .NET (C# F#, PowerShell, etc)✔  Node.js✔  Perl ✔  PHP✔  Python✔  Ruby✔  Scala
    • MongoDbLinux/Unix OS X Windows32 e 64 bits
    • MongoDb
    • MongoDbInstalando
    • InstalandoLinuxFácil:  apt­get/aptitude/yum install mongodbPouco fácil:curl http://downloads.mongodb.org/linux/mongodb­linux­x86_64­x.y.z.tgz > mongo.tgztar ­zxvf mongo.tgzmkdir ­p /data/dbchown mongo /data/dbmongod ­­config /etc/mongod.conf
    • InstalandoOS XFácil: brew/port install mongodbPouco Fácil: curl http://downloads.mongodb.org/osx/mongodb­osx­i386­x.y.z.tgz > mongo.tgztar ­zxvf mongo.tgzsudo mkdir ­p /data/dbsudo chown `id ­u` /data/dbmongod ­­config /etc/mongod.conf
    • InstalandoWindowsDifícil:cd move C:mongodb­win32­* C:mongodbmd datamd datadbC:mongodbbinmongod.exe(Depending on the security level of your system, Windows will issue a Security Alert dialog box about blocking “some features” of C:mongodbbinmongod.exe)md C:mongodblogecho logpath=C:mongodblog > C:mongodbmongod.cfgC:mongodbbinmongod.exe ­­config C:mongodbmongod.cfg –installnet start MongoDB
    • Suporte ao MongoDB no PHP
    • Suporte ao MongoDB no PHP PHP >5.1 Linux, OS X e Windows 32 e 64 bits
    • Instalando a Extensão mongo ao PHP
    • Instalando a Extensão Linux sudo pecl install mongo extension=mongo.so OS X sudo pecl install mongo  extension=mongo.so Windows Go to http://www.php.net/manual/en/mongo.installation.php#mongo.installation.windows extension=php_mongo.dll
    • Usando o MongoDB no PHP
    • MongoDB no PHP Por que? Web Apps Informações Rápidas Escalabilidade Cache
    • MongoDB no PHP Criando uma Conexão $m = new Mongo();  // conecta a localhost:27017 Ou$m = new Mongo(exemplo.com:1337);  // conecta ao host  exemplo.com na porta 1337
    • MongoDB no PHP Selecionando um banco de dados$db = $m­>phpms; //seleciona o banco de dados phpms Selecionando uma coleção $participants = $db­>participants;
    • MongoDB no PHP Inserindo dados$participants ­>insert(array( name => jose);$participants ­>insert(array( name => maria, cpf => 12345678901);
    • MongoDB no PHP Executando um comando$db­>execute(db.insert({participants: {name:”jose”}}));
    • MongoDB no PHP Tipos de Dados
    • MongoDB no PHPMongoInt32: Inteiro de 32 bits num sistema 64 bits $i = new MongoInt32(123.45);MongoInt64: Inteiro de 64 bits num sistema 32 bits $i = new MongoInt64(123.45);MongoDate: Data/Hora em milisegundos $date = new MongoDate(strtotime(2012­08­17 18:00:00));
    • MongoDB no PHPBuscando num intervalo de datas $start = new MongoDate(strtotime("2012­08­17 00:00:00")); $end = new MongoDate(strtotime("2012­09­01 00:00:00")); $participants­>find(array( “inscription_date” => array( $gt => $start,  $lte => $end ) ) );
    • MongoDB no PHPBuscando num intervalo de datas $start = new MongoDate(strtotime("2012­08­17 00:00:00")); $end = new MongoDate(strtotime("2012­09­01 00:00:00")); $collection­>find(array( “inscription_date” => array( $gt => $start,  $lte => $end ) ) );
    • MongoDB no PHPMongoDB nos Frameworks PHP
    • MongoDB nos Frameworks PHP CakePHP CodeIgniter Drupal Kohana Lithium Symfony Zend Etc.