This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$pdo = new PDO('mysql:host=localhost;dbname=teste', 'admin', "baruch hashem"); | |
$stmt = $pdo->prepare('DELETE FROM contador WHERE email = :id'); | |
$stmt->execute( | |
array( | |
':id' => '[email protected]' | |
) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$pdo = new PDO('mysql:host=localhost;dbname=teste', 'admin', "Sua senha[O ideal é que ela seja uma varipavel]"); | |
$data = "[email protected]"; | |
/* aqui pode ser usado o $_GET ou qualquer recebimentos NÃO se esqueça de usar o filter_var */ | |
/* o prepare faz o que faria o query, dentro dela é apenas inserir códigos do sql, nesse exemplo usei o mariadb, mas ele pode | |
ser qualquer um outro e o código será o mesmo, se for sql | |
*/ | |
$stmt = $pdo->prepare("INSERT INTO contador (email) VALUES(:email)"); | |
/* Aqui pode mandar os dados no formato de array usando o execute() função nativa, pode usar um json_decode() em caso de |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = $connDB->prepare('SELECT * FROM topic WHERE topic_name LIKE :keywords'); | |
$query->bindValue(':keywords', '%' . $searchQ . '%'); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*{ | |
}/* Onde fica o artigo*/ | |
#conteudo>p{ | |
text-align:justify; | |
margin:20px; | |
font-size: 20px; | |
font-family: medium-content-sans-serif-font,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue", sans-serif; | |
color:#333; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = file_get_contents( "http://dados.ufrn.br/api/action/datastore_search?resource_id=ff0a457e-76fa-4aca-ad99-48aebd7db070&limit=1" ); | |
// Aqui vai ser o linnk do json que irão mandar | |
$users = json_decode ( $url, true ); | |
// essa variavel $users irá pegar o json e transforma-la em array | |
$OqueEuQueroDoJson = "nome"; | |
print_r($users["result"]["records"][0][$OqueEuQueroDoJson]); | |
//print_r no caso faz com que ele exiba array.. e assim fica mais facil pra vc pegar alguma informação | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcelo ' ], | |
[ 'idade' => 50, 'nome' => 'Marcos dougras' ], | |
]; | |
function mapear( $dados ){ | |
return $dados['idade']; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcelo ' ], | |
[ 'idade' => 50, 'nome' => 'Marcos dougras' ], | |
]; | |
function passa ( $val, $w ){ | |
$val["idade"] += $w["idade"];// aqui ele vai pegar o valor do array e irá somar. | |
return $val; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcelo ' ], | |
[ 'idade' => 50, 'nome' => 'Marcos dougras' ], | |
]; | |
function passa ( $val, $w ){ | |
$val["idade"] += $w["idade"];// aqui ele vai pegar o valor do array e irá somar. | |
return $val; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
function passa ( $val ){ | |
$saida = 'Marco';// isso abaixo é tudo o que começar com $saida | |
return substr( $val[ 'nome' ], 0, strlen($saida)) == $saida ? $val : false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
function passa ( $val ){ | |
return $val[ 'nome' ]; | |
}// Isso é uma função pura :) |