Presentation is loading. Please wait.

Presentation is loading. Please wait.

Com Jean Carlo Nascimento aka SUISSA. github.com/suissa about.me/suissa

Similar presentations


Presentation on theme: "Com Jean Carlo Nascimento aka SUISSA. github.com/suissa about.me/suissa"— Presentation transcript:

1 com Jean Carlo Nascimento aka SUISSA

2 github.com/suissa about.me/suissa nosqlbr.com.br @osuissa

3 NOSQL O que é? Quais são? Por que usar? Onde usar?

4

5

6

7

8

9

10

11

12 key/value

13

14 graph

15

16

17

18

19

20

21

22

23

24 Terminologia SQL RDBMS DATABASE TABLE ROWS QUERY INDEX PARTITION MongoDB DATABASE COLLECTION JSON DOCUMENT QUERY INDEX SHARD

25 INSERIR INSERT INTO USERS VALUES(1,1) $db->users->insert(array("a" => 1, "b" => 1)); //ou $query = array( 'usuario' => "suissa", 'email' => "jnascimento@gmail.com" ); $db->collection->insert($query);

26 CONSULTAR select * from tabela where nome = 'Jean Nascimento' $filter = array( "nome" => "Jean Nascimento" ); $cursor = $collection->find($filter); foreach ($cursor as $arr) { echo $arr["nome"]. " - ". $arr["_id"]. " "; }

27 CONSULTAR select * from tabela where nome LIKE 'J___ Nascimento' $filter = array( "nome" => new MongoRegex('/^J[a-Z]{3} Nascimento/i' ); select * from tabela where nome LIKE '%Nasc%' $filter = array( 'title' => new MongoRegex('/.Nasc./i') );

28 ALTERAR update tarefas set Tarefa='Terminar artigo' where Usuario='suissa' $db->collection->update( array('Usuario'=> 'suissa'), array('$set' => array('Tarefa' => 'Terminar artigo')) ); update users set a=a+2 where b='q' $db->users->update(array("b" => "q"), array('$inc => array("a" => 2)));

29 EXCLUIR delete from usuarios where Usuario = 'suissa' $db->collection->remove(array('Usuario'=> 'suissa'));

30 EXPLAIN EXPLAIN SELECT * FROM users WHERE z=3 $db->users->find(array("z" => 3))->explain()

31

32

33

34

35 Talk is cheap. Show me the code.

36 $nome_banco = ‘prioridades’; $nome_collection = ‘tarefas’; $this->conexao = new Mongo(); $this->db = $this->conexao->$nome_banco; $this->collection = $this->db->$nome_collection;

37 function inserir(){ $this->query = array( ‘UsuarioID’ => $this->UsuarioID, ‘Usuario’ => $this->Usuario, ‘Tarefa’ => $this->Tarefa, ‘Tipo’ => $this->Tipo,//Obrigatório, idéia, outro ‘Prioridade’ => $this->Prioridade); $this->collection->insert($this->query); }

38 function excluir(){ $this->mongo_id = new MongoID($this->_id); $this->collection->remove(array(‘_id’ => $this->mongo_id)); }

39 function mudar_tarefa(){ $this->mongo_id = new MongoID($this->_id); $this->collection->update(array(‘_id’ => $this->mongo_id), array(‘$set’ => array(‘Tarefa’ => $this->Tarefa)), false); }

40 function mudar_tarefa(){ $this->mongo_id = new MongoID($this->_id); $this->collection->update(array(‘_id’ => $this->mongo_id), array(‘$set’ => array(‘Tarefa’ => $this->Tarefa)), false); }

41 function mudar_prioridade(){ $this->mongo_id = new MongoID($this->_id); if($this->modo==’up’){ $this->collection->update( array(‘_id’ => $this->mongo_id), array(‘$inc’ => array(‘Prioridade’ => 1)), false ); } elseif($this->modo==’down’){ $this->collection->update( array(‘_id’ => $this->mongo_id), array(‘$inc’ => array(‘Prioridade’ => -1)), false ); }

42 https://github.com/suissa/mongodb-exemplos

43 Frameworks CakePHP Codeigniter Doctrine Drupal Fat-Free Kohana Lithium Memcached Symfony 2 TechMVC Vork Yii Zend

44 Standalone Tools ActiveMongo MapReduce API Mongofilesystem Mandango MongoDb PHP ODM Mongodloid MongoQueue MongoRecord Morph simplemongophp Uniform Server 6-Carbo with MongoDB and phpMoAdmin

45 Referências http://www.nosqlbr.com.br/ http://nosql-database.org/ http://pt.wikipedia.org/wiki/NoSQL http://www.mongodb.org/

46


Download ppt "Com Jean Carlo Nascimento aka SUISSA. github.com/suissa about.me/suissa"

Similar presentations


Ads by Google