PHP é uma linguagem de processamento interpretada pelo servidor
Esta é a terceira aula do curso de Web Development organizado pela MozDevz, mais informações visite: www.mozdevz.org
Using Geeklog as a Web Application FrameworkDirk Haun
Slides for the workshop "Using Geeklog as a Web Application Framework", as held at
- LinuxTag 2006, Wiesbaden, Germany, 2006-05-06
- PHP user group meeting, Stuttgart, Germany, 2006-05-10
- FrOSCon, Bonn, Germany, 2006-06-24
Everyone wants to jump into HTML5 but how do you use the cool features of this new specification while ensuring existing and future browsers render your web pages as expected? This is where feature detection, Modernizr, polyfills and shims come in. In the session, you’ll learn the best practices and strategy to code with HTML5 and CSS3 features that won’t break for the existing and future browsers. You’ll learn step by step how to use specially crafted JavaScript and CSS code that emulate HTML5 features. Also, a real-life case study will be used to demonstrate step by step how to build Cross-Browser Plug-in-Free experiences. With a couple of simple changes to your sites, you can take advantage of HTML5 today without breaking your sites in the future. Expect a lot of demos and code in the session.
Using Geeklog as a Web Application FrameworkDirk Haun
Slides for the workshop "Using Geeklog as a Web Application Framework", as held at
- LinuxTag 2006, Wiesbaden, Germany, 2006-05-06
- PHP user group meeting, Stuttgart, Germany, 2006-05-10
- FrOSCon, Bonn, Germany, 2006-06-24
Everyone wants to jump into HTML5 but how do you use the cool features of this new specification while ensuring existing and future browsers render your web pages as expected? This is where feature detection, Modernizr, polyfills and shims come in. In the session, you’ll learn the best practices and strategy to code with HTML5 and CSS3 features that won’t break for the existing and future browsers. You’ll learn step by step how to use specially crafted JavaScript and CSS code that emulate HTML5 features. Also, a real-life case study will be used to demonstrate step by step how to build Cross-Browser Plug-in-Free experiences. With a couple of simple changes to your sites, you can take advantage of HTML5 today without breaking your sites in the future. Expect a lot of demos and code in the session.
From our "PHP Open Day" - Tal Tamir's lacture.
Today, every simple application requires working with databases. The lecture was intended to show a simple and effective way to work in PHP with DB's
The WordPress REST API is a powerful tool that can enhance your web development projects. In this presentation, attendees will learn how to leverage WordPress's existing endpoints and create custom ones using PHP without needing plugins. Attendees will also learn how to use their endpoints to power their front-end React apps, web apps or even entirely separate websites. Finally, attendees will learn about security concerns and how to lock down the REST API. Time permitting, attendees can have a Q&A period to ask questions.
The WordPress REST API was introduced in 2016 in version 4.7. It has been part of the WordPress ecosystem for about seven years and is well-documented. With the introduction of React and Gutenberg blocks, the REST API can take on a new life to help developers create complex apps with relative ease. Where once it was primarily used for basic integrations, now developers are harnessing its full capabilities for ambitious projects. The WordPress REST API can power modern web applications and custom blocks, showing that it remains highly relevant for building on the web today. Even after years of existence, the REST API remains a cornerstone of the WordPress framework.
The API-first design approach treats APIs as first-class citizens. The entire system or project is built around the idea that components connect via APIs. The first step is, therefore, to design the APIs and their connections.
However, there is a gap between the beautiful world of API specifications and the reality of agile development. This gap means that published API specifications are often incomplete, missing examples or simply outdated. The API specification meant to help developers can be a thorn in one’s side because keeping the specification in sync with its implementation is a manual process, tedious and prone to be forgotten during the rush to deliver.
We show how this gap can be bridged effectively using the API specification as the only source of truth driving the API implementation with proven tools enabling automation.
A presentation for Dundee University's Hack Day explaining the technologies to use and how to hack your own APIs by using Yahoo! Pipes and scraping RSS feeds.
From our "PHP Open Day" - Tal Tamir's lacture.
Today, every simple application requires working with databases. The lecture was intended to show a simple and effective way to work in PHP with DB's
The WordPress REST API is a powerful tool that can enhance your web development projects. In this presentation, attendees will learn how to leverage WordPress's existing endpoints and create custom ones using PHP without needing plugins. Attendees will also learn how to use their endpoints to power their front-end React apps, web apps or even entirely separate websites. Finally, attendees will learn about security concerns and how to lock down the REST API. Time permitting, attendees can have a Q&A period to ask questions.
The WordPress REST API was introduced in 2016 in version 4.7. It has been part of the WordPress ecosystem for about seven years and is well-documented. With the introduction of React and Gutenberg blocks, the REST API can take on a new life to help developers create complex apps with relative ease. Where once it was primarily used for basic integrations, now developers are harnessing its full capabilities for ambitious projects. The WordPress REST API can power modern web applications and custom blocks, showing that it remains highly relevant for building on the web today. Even after years of existence, the REST API remains a cornerstone of the WordPress framework.
The API-first design approach treats APIs as first-class citizens. The entire system or project is built around the idea that components connect via APIs. The first step is, therefore, to design the APIs and their connections.
However, there is a gap between the beautiful world of API specifications and the reality of agile development. This gap means that published API specifications are often incomplete, missing examples or simply outdated. The API specification meant to help developers can be a thorn in one’s side because keeping the specification in sync with its implementation is a manual process, tedious and prone to be forgotten during the rush to deliver.
We show how this gap can be bridged effectively using the API specification as the only source of truth driving the API implementation with proven tools enabling automation.
A presentation for Dundee University's Hack Day explaining the technologies to use and how to hack your own APIs by using Yahoo! Pipes and scraping RSS feeds.
A RESTful Introduction will cover the basics of what REST means and takes advantage of. We will talk about status codes, verbs and APIs in general.
The presentation was held by Daniel Toader and Andrei Pirjoleanu from eMAG.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Epistemic Interaction - tuning interfaces to provide information for AI support
Web Training Aula 02: Introduction to PHP
1. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Web Development Training
PHP Básico
Definição
Preparação de ambiente
Sintaxe / Operações básicas
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
1
2. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
O que é PHP ?
• linguagem interpretada
• Interpretado do Servidor
• HTML+CSS+JavaScript+PHP
• arquivos PHP tem extensão
" .php "
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
2
3. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Seu Poder
• PHP pode gerar páginas com
conteúdo dinâmico
• PHP pode criar, abrir, ler,
escrever, apagar e fechar
arquivos no servidor
• PHP pode coletar dados de
formulários
• PHP pode enviar e receber
cookies
• PHP pode adicionar, eliminar,
modificar dados na base de
dados
• PHP pode ser usado para
controlar o acesso de
utilizadores
• PHP pode criptografar os
dados
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
3
4. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Instalação
• Encontrar um host com PHP e suporte ao MySQL
• Instalar um servidor web no seu próprio PC, em seguida,
instalar o PHP e MySQL
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
4
5. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Declaração
<?php
//O código PHP fica aqui!
?>
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
5
6. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Variaveis
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
6
7. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Comentários
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
# Isto é apenas um comentário
// Isto também é um comentário
/* comentário */
7
8. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
ECHO
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
<?php
$txt1 = "Learn PHP";
$txt2 = "W3Schools.com";
$x = 5;
$y = 4;
echo "<h2>$txt1</h2>";
echo "Study PHP at $txt2<br>";
echo $x + $y;
?>
8
9. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
If – Then - Else
if (condição) {
Código que é executado se a condição fôr
verdadeira;
}
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
$x = 2; # Variáveis
if ($x >= 1 && $x < 3) { // se a variavel $x for
maior ou igual a 1 E(AND) menor que 3
echo 'Olá mundo!'; // escreve "Olá mundo!"
} else { // Se não...
print('Adeus mundo!'); // escreve 'Adeus
mundo!', print e echo podem ser usados com ou sem
parênteses.
}
9
10. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Web Development Training
Formulários e PHP
Ruben Manhiça
Jorge Lobo
Hervé Muneza
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
10
11. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Conceptos por aprender
• Formulários
• Métodos GET e POST
• Acesso no Servidor
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
The image part with relationship ID rId2 was not found in the file.
11
12. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Formulários
• Permite enviar
dados para o
servidor
• Pode ser enviado
usando os
métodos POST e
GET
<html>
<body>
<form action =”processar.php”
method=”post">
Name: <input type=”text” name=”nome” />
Age: <input type=”text” name=idade” />
<input type=”submit” />
</form>
</body>
</html>
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
12
13. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
GET e POST
Criam um vetor com um par de
chaves/valores.
Chaves – nomes de
controle do formulário;
v a l o r e s – d a d o s
introduzidos no formulários .
html>
<body>
<form action =”processar.php”
method=”get">
Name: <input type=”text”
name=”nome” />
....
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
13
14. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
GET
Tem a limitação de só enviar 100 caracteres;
Mostra a informação enviada no Navegador;
Permite guardar a requisição ao Servidor no Bookmarks;
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
The image part with relationship ID rId2 was not found in the file.
14
15. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
POST
Método POST
Não tem limite de tamanho da
mensagem a enviar;
A informação enviada não é
visível no navegador;
html>
<body>
<form action =”processar.php”
method=”post">
Name: <input type=”text”
name=”nome” />
....
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
15
16. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Acesso do Servidor
Método GET
$_GET[”nome"]
Método POST
$_POST[”nome"]
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
16
17. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Exemplo
Index.php
html>
<body>
<form action =”processar.php”
method=”post">
Name: <input type=”text” name=”nome” /
>
Age: <input type=”text” name=idade” />
<input type=”submit” />
</form>
</body>
</html>
Processar.php
<?php
If(empty($_POST["nome"])) {
echo ”Preencha o seu nome”;
} else {
$nome = $_POST["nome"];
}
?>
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
17
18. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Referencias
• Lengstorf, Jason. PHP For Absolute Beginners. [New
York.]: Apress, 2009. Print.
• Welling, Luke, and Laura Thomson. PHP And Mysql
Web Development. Upper Saddle River, NJ: Addison-
Wesley, 2008. Print.
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
18
19. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Web Development Training
PHP e MySQL
Ruben Manhiça
Jorge Lobo
Hervé Muneza
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
19
20. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Acesso ao servidor
• Passo 1 - Abrir conexão com o banco.
• Antes de criarmos a conexão com o banco devemos ter em mãos algumas
informações. São elas:
• Utilizador – Nome de Utilizador com acesso a base de dados.
• Senha – Senha do Utilizador.
• Host – Nome ou IP do servidor. Ex: “localhost”
• De posse dessas informações podemos criar nossa conexão com a Base
de dados utilizando o comando mysql_connect();
mysql_connect(host, Utilizador, senha);
• Em caso de sucesso, este comando retorna um identificador de
conexão. Em caso de falha este comando retornará FALSE.
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
20
21. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Acesso ao servidor
• Exemplo
$conexao = mysql_connect(“host”,“Utilizador”, “senha”);
if ($conexao == TRUE){
echo “Conexão com o servidor efetuada com sucesso.”;
}else{
echo “Falha ao conectar no servidor.”;
}
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
21
22. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Acesso ao servidor
• Passo 3 – Fechar conexão com o Base de dados.
• Após a execução dos comandos no banco devemos fechar a conexão
com o servidor para poupar recursos do servidor.
• Para fechar a conexão com o banco utilizamos a função
mysql_close().
mysql_close(identificador de conexão);
• O comando mysql_close() retorna TRUE em caso de sucesso e
FALSE em caso de falha;
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
22
23. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Acesso ao servidor
• Exemplo
$conexao = mysql_connect(“host”,“Utilizador”, “senha”);
if ($conexao == TRUE){
echo “Conexão com o servidor efetuada com sucesso.”;
}else{
echo “Falha ao conectar no servidor.”;
}
if(mysql_close($conexao)){
echo “Conexão com o banco fechada com sucesso.”;
}else{
echo “Não havia conexão aberta ou a conexão já tinha sido fechada.”;
}
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
23
24. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Manipulação de
Dados
• Passo 2 – Executar comandos na Base de dados.
• Após conectar no servidor de Base de dados, devemos especificar
qual base de dados será utilizada. Isto é feito através da função
mysql_select_db();
mysql_select_db(nome do banco);
• A execução de comandos no MySQL é feita através de declarações
SQL.
• Após a definição do comando, podemos executar o comando no
banco através do método mysql_query();
mysql_query(declaração_sql);
• Além disso, ao executar o comando, esta função faz com que a
variável que estiver representando-a, armazene informações a
respeito da instrução SQL executada.
$variavel = mysql_query(declaração_sql);
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
24
25. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Manipulação de
Dados
• O tipo de informações armazenadas dependerão do tipo de instrução
SQL executada.
• Para outros tipos de consultas SQL, INSERT, UPDATE, DELETE, DROP,
etc, mysql_query() retorna TRUE em caso de sucesso ou FALSE em
caso de erro.
• Para comandos SELECT, SHOW, DESCRIBE ou EXPLAIN,
mysql_query() retorna um resource em caso de sucesso, ou FALSE em
caso de falha.
• Neste último caso, os resultados da instrução SQL podem ser acessadas
através de outras funções da biblioteca mysql.
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
25
26. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Manipulação de
Dados
• O recurso de resultado retornado pode ser passado para
mysql_fetch_array(), e outras funções para manipular tabelas de
resultados, para acessar os dados retornados.
• Use mysql_num_rows(query) para obter quantas linhas foram retornadas
para um comando SELECT ou mysql_affected_rows(link resource) para
obter quantas linhas foram afetadas por um comando DELETE, INSERT,
REPLACE, ou UPDATE.
• mysql_query() irá também falhar e retornar FALSE se o Utilizador não
tiver permissões para acessar a tabela(s) referenciadas pela consulta.
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
26
27. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Manipulação de
Dados
• Exemplo do uso de comando INSERT:
$conexao = mysql_connect(“host”,“Utilizador”, “senha”);
$banco = mysql_select_db(“banco”);
$sql = “INSERT INTO FUNCIONARIO (MATRICULA, NOME) VALUES (1,’FULANO’)”;
$resultado = mysql_query($sql, $conexao);
if ($resultado){
$numeroRegistros = mysql_affected_rows($conexao);
echo “Comando executado com sucesso. ”;
echo “Foram afetados $numeroRegistros registros.”;
}else{
echo “Falha ao executar comando.”;
}
mysql_close($conexao);
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
27
28. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Manipulação de
Dados
• No caso de comandos que retornam informações da BD, podemos utilizar algumas
funções para extrair as informações armazenadas no recurso de resultado. São
elas:
• mysql_fetch_row – recupera o próximo registro em forma de array de índices numéricos.
• mysql_fetch_assoc – recupera o próximo registro em forma de array de índices
associativos, onde cada índice é o nome do campo na tabela.
• mysql_fecth_array – recupera o próximo registro em forma de array de índices numéricos
e associativos, ao mesmo tempo.
• mysql_fecth_object - recupera o próximo registro em forma de objeto.
• Todas elas necessitam como parâmetro do recurso contendo o resultado do
comando mysql_query()
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
28
29. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Base de dados – MySQL – Manipulação de
Dados
• Exemplo do uso de comando SELECT:
$conexao = mysql_connect(“Utilizador”, “senha”, “host”);
$banco = mysql_select_db(“banco”);
$sql = “SELECT matricula, nome, salario FROM funcionario”;
$resultado = mysql_query($sql, $conexao,);
if ($resultado){
while ($registro = mysql_fecth_array($resultado)){
echo “Matricula: ”.$registro[”matricula”];
echo “Nome: ”. $registro[”nome”];
echo “Salário: ”. $registro[”salario”];
}
}
mysql_close($conexao);
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
29
30. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Herança
• Permite reutilizar uma
classe ou expandir para
diferente proposito.
• A classe filho herda os
métodos e propriedades
da classe pai.
• Construtores ???
<?php
Class cao extends mamifero {
...
}
?>
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
30
31. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Web Development Training
MVC
Model – View - Controller
Definição
Model
Controller
View
Vantagem
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
31
32. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
O que é MVC?
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
"MVC é um padrão de arquitetura que descreve uma
forma de estruturar nossa aplicação e as
responsabilidades e interações para cada parte nessa
estrutura."
32
33. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
MVC
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
33
34. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Model (Modelo)
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
O modelo é o de dados e as regras aplicáveis a
esses dados, que representam conceitos geridos
por uma aplicação
34
35. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Controller (Controlador)
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
O controlador gere as solicitações do utilizador (recebidos como
HTTP GET ou POST solicitados quando o utilizador clica em
elementos GUI para executar ações)
Sua principal função é chamar e coordenar os recursos
necessários / objetos necessários para executar a ação do
utilizador
35
36. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Exemplo - Controller (Controlador)
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
<?php
class BooksController extends AppController {
function list($category) {
$this->set('books', $this->Book-
>findAllByCategory($category));
}
function add() { ... ... }
function delete() { ... ... }
... ... } ?>
36
37. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
View
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
View oferece maneiras diferentes de apresentar os dados
recebidos a partir do modelo.
<table> <tr> <th>Title</th> <th>Author</th>
<th>Price</th> </tr>
<?php foreach ($books as $book): ?> <tr> <td> <?
php echo $book['Book']['title']; ?> </td> <td> <?
php echo $book['Book']['author']; ?> </td> <td>
<?php echo $book['Book']['price']; ?> </td> </tr>
<?php endforeach; ?>
</table>
37
38. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
MVC
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
38
39. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Vantagem
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
"A vantagem mais óbvia que ganhamos usando MVC é uma clara
separação de apresentação (a interface com o utilizador) e lógica
da aplicação.”
39
40. The image
part with
relationshi
p ID rId14
was not
found in
the file.
The image part with relationship ID rId14 was not found in
the file.
Para proxima semana
• Dar vida aos formularios…
3/28/16
Presenta/on licenced under non-commercial crea/ve
commons 3.0
40