This file contains 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 | |
// newPDO: connectem amb la BD | |
$usuari="root"; | |
$password=""; | |
$database ="uf3"; | |
$host = "localhost"; | |
try { | |
$bd = new PDO('mysql:host='.$host.';dbname='.$database, |
This file contains 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 | |
// definició de variables | |
$nom = "Marta"; // variables de text o cadena (String) | |
$cognom1 = "Salelles"; | |
$cognom2 = "Ballarà"; |
This file contains 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 | |
// Array amb les parades d'una línia | |
// De cada parada, tenim: | |
// - el nom de la parada | |
// - El temps que triga el tren fins arribar a la següent parada | |
// - Els km que separen l'estació actual i la següent estació | |
// - L'adreça on es troba aquesta parada | |
// - Estat en que es troba l'estació: oberta o tancada | |
$linia1 = [ |
This file contains 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 | |
class Model { | |
protected $bd; | |
protected $usuari="root"; | |
protected $password="usuari"; | |
protected $taula; | |
protected $database ="supersBD"; | |
protected $host = "localhost"; |
This file contains 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 | |
include_once 'Model.php'; | |
class Superheroes extends Model{ | |
protected $taula="heroes"; | |
// Afegir a la BD un nou superheroi | |
public function add($heroname,$realname,$gender,$race) { |
This file contains 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 | |
include_once 'Model.php'; | |
class Usuaris extends Model{ | |
protected $taula ="usuaris"; | |
// Afegir mètode per afegir un nou usuari | |
This file contains 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 | |
error_reporting(E_ALL); | |
ini_set('display_errors', '1'); | |
session_start(); | |
// url de la forma: index.php?control=nomControlador | |
if (isset($_GET['control'])) { | |
$control = $_GET['control']; |
This file contains 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
// resources/views/planets/api/index.blade.php | |
@extends('plantilla') | |
@section('content') | |
CRUD PLANETES | |
<div> | |
<input type="text" id="planetNameInput"> | |
<button id="saveButton" >Save</button> | |
</div> | |
This file contains 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 | |
namespace App\Http\Controllers\api; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Http\Request; | |
use App\Models\Planet; | |
use Validator; | |
This file contains 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
// Canvis en el fitxer app.js o server.js o index.js | |
// Instal·lar mòdul CORS : npm install cors | |
// Habilita crides CORS: Crides des de diferents origens permeses | |
app.use(cors()) | |
//app.use(express.urlencoded({ extended: true })); | |
// Comentar línia anterior: enviament dades per formulari |
OlderNewer