mysqli 创建表

   $servername = "localhost";
        $username = "root";
        $password = "root";
        $dbname = "shuju";
        $conn = new \mysqli($servername, $username, $password, $dbname);
        $sql = "CREATE TABLE user (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
username VARCHAR(30) NOT NULL,
password VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)";
        if ($conn->query($sql) === TRUE) {
            echo "创建成功";
        } else {
            echo "创建失败";
        }
        $conn->close();
        die;
drop procedure if exists p_demo;
delimiter //
create procedure p_demo()
begin
 set @SqlStr = 'select count(1) into @i from t_log;';
    prepare SqlStr from @SqlStr;
    execute SqlStr;
    deallocate prepare SqlStr;
    select @i;
end;
//
delimiter ;

call p_demo();

你可能感兴趣的:(mysqli 创建表)