标签:version exce unsigned isp database opened create mem mac
* 数据表
-- MySQL dump 10.16 Distrib 10.1.31-MariaDB, for osx10.6 (i386) -- -- Host: localhost Database: laravel -- ------------------------------------------------------ -- Server version 10.1.31-MariaDB /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE=‘+00:00‘ */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=‘NO_AUTO_VALUE_ON_ZERO‘ */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `users` -- DROP TABLE IF EXISTS `users`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `password` varchar(60) NOT NULL, `remember_token` varchar(100) DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00‘, `updated_at` timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00‘, PRIMARY KEY (`id`), UNIQUE KEY `users_email_unique` (`email`) ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `users` -- LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` VALUES (1,‘mingzhanghui‘,‘xxx@qq.com‘,‘123456‘,NULL,‘2018-06-30 16:00:00‘,‘2018-07-12 16:00:00‘),(2,‘username#0‘,‘0@qq.com‘,‘123456‘,‘ed3d2c21991e3bef5e069713af9fa6ca‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(3,‘username#1‘,‘1@qq.com‘,‘123456‘,‘3416a75f4cea9109507cacd8e2f2aefc‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(4,‘username#2‘,‘2@qq.com‘,‘123456‘,‘43ec517d68b6edd3015b3edc9a11367b‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(5,‘username#3‘,‘3@qq.com‘,‘123456‘,‘182be0c5cdcd5072bb1864cdee4d3d6e‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(6,‘username#4‘,‘4@qq.com‘,‘123456‘,‘2a38a4a9316c49e5a833517c45d31070‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(7,‘username#5‘,‘5@qq.com‘,‘123456‘,‘ac627ab1ccbdb62ec96e702f07f6425b‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(8,‘username#6‘,‘6@qq.com‘,‘123456‘,‘2a38a4a9316c49e5a833517c45d31070‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(9,‘username#7‘,‘7@qq.com‘,‘123456‘,‘f033ab37c30201f73f142449d037028d‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(10,‘username#8‘,‘8@qq.com‘,‘123456‘,‘03afdbd66e7929b125f8597834fa83a4‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘),(11,‘username#9‘,‘9@qq.com‘,‘123456‘,‘33e75ff09dd601bbe69f351039152189‘,‘2018-07-21 09:28:37‘,‘2018-07-21 09:29:37‘); /*!40000 ALTER TABLE `users` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2018-07-22 12:07:18
* php 代码片段
<?php $settings = [ ‘host‘ => ‘127.0.0.1‘, ‘port‘=> 3306, ‘name‘ => ‘laravel‘, ‘username‘ => ‘root‘, ‘password‘ => ‘‘, ‘charset‘ => ‘utf8‘ ]; try { $pdo = new PDO( sprintf( ‘mysql:host=%s;dbname=%s;port=%d;charset=%s‘, $settings[‘host‘], $settings[‘name‘], $settings[‘port‘], $settings[‘charset‘] ), $settings[‘username‘], $settings[‘password‘] ); } catch (PDOException $e) { echo "Database connection failed: ".$e->getMessage(); exit; } // $sql = ‘SELECT * from users where email=:email‘; $sql = ‘SELECT * from users where id < :id‘; $statement = $pdo->prepare($sql); // $email = filter_input(INPUT_GET, ‘email‘); // $statement->bindValue(‘:email‘, ‘8@qq.com‘, PDO::PARAM_STR); $statement->bindValue(‘:id‘, 8, PDO::PARAM_INT); $statement->execute(); // while (($result = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { // echo $result[‘email‘].PHP_EOL; // } while (($o = $statement->fetchObject()) !== false) { echo $o->email.PHP_EOL; } // transanction // $pdo->beginTransaction(); // ... // $pdo->commit();
* output
chenhuimingdeMacBook-Pro:database Mch$ php pdo.php
xxx@qq.com
0@qq.com
1@qq.com
2@qq.com
3@qq.com
4@qq.com
5@qq.com
标签:version exce unsigned isp database opened create mem mac
原文地址:https://www.cnblogs.com/mingzhanghui/p/9349639.html