Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 1.49 KB

Clase7.md

File metadata and controls

57 lines (48 loc) · 1.49 KB

conexiones a BD

https://www.w3schools.com/php/php_mysql_connect.asp

seleccionar filas

https://dev.mysql.com/doc/refman/8.0/en/retrieving-data.html https://www.w3schools.com/php/php_mysql_select.asp

paso a paso

  • ir a ejemploBaseDatos de esta clase
  • levantar docker:
docker-compose up -d
  • comprobar maquinas:
docker ps
  • conectar la base de datos (los datos estan en docker-compose)
host: localhost
port: 9906
user: root
pass: rootsecretpass
  • crear tabla de users
CREATE TABLE `clase7`.`users` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(45) NOT NULL,
  `email` VARCHAR(45) NOT NULL,
  `sexo` ENUM('F', 'M', 'N') NOT NULL,
  PRIMARY KEY (`id`));
  • insertar valores
INSERT INTO `clase7`.`users` (`name`, `email`, `sexo`) VALUES ('mari', 'mari@fakemails', 'F');
INSERT INTO `clase7`.`users` (`name`, `email`, `sexo`) VALUES ('rosa', '[email protected]', 'F');
INSERT INTO `clase7`.`users` (`name`, `email`, `sexo`) VALUES ('luis', '[email protected]', 'M');
INSERT INTO `clase7`.`users` (`name`, `email`, `sexo`) VALUES ('komai', '[email protected]', 'N');
INSERT INTO `clase7`.`users` (`name`, `email`, `sexo`) VALUES ('mario', '[email protected]', 'M');
INSERT INTO `clase7`.`users` (`name`, `email`, `sexo`) VALUES ('paqui', '[email protected]', 'F');
INSERT INTO `clase7`.`users` (`name`, `email`, `sexo`) VALUES ('antonio', '[email protected]', 'M');
  • como ver la estructura con la que creé una tabla

SHOW CREATE TABLE users;