PHP使用Medoo在mysql获取表字段名称和字段信息的方法

PHP Framework 数据库框架 Medoo 2.1:初识Medoo PHP数据库框架Medoo 2.1:Medoo简介什么是Medoo?引用Medoo 2.1下载Medoo存放Medoo确定Medoo支持的数据库与PHP版本 什么是Medoo? Medoo是一款轻量级的PHP数据库框架,现在最新版为2.1.0,它可以操作的数据库有很多,现在官方文档里,明确指出支持的数据库有:MySQL、MariaDB、MSSQL、Oracle、SQLite、PostgreSQL、Sybase。 我们可以在自己平时使用的PHP开发框架中集成它,也可以在原生的PHP代码里使用它。 我曾经在博客 阅读详情

欢迎移步到新博客中阅读同篇此文

http://exp.szer.me/parry/blog/wordpress/index.php/2018/06/29/medoo-col/

Medoo微框架中也支持原生查询,从而可以通过执行sql指令 SHOW COLUMNS FROM TABLE来获取字段列信息。

$database = new Medoo([
        'database_type' => DATABASE_TYPE,
        'database_name' => DATABASE_NAME,
        'server' => SERVER,
        'username' => USERNAME,
        'password' => PASSWORD,
        'port' => PORT,
        'charset' => CHARSET
    ]);


$columns = $database->query("SHOW COLUMNS FROM $table")->fetchAll();
//$columns里有全部的数据信息 

unset($field_list);
$field_list = [];

foreach ($columns as $col){
    //var_dump($col);
    /** col是一个数组 里面包含表内一个字段列的信息
    可以用数字或字符索引
     array(12) { 
    ["Field"]=> string(2) "id" 
    [0]=> string(2) "id" 
    ["Type"]=> string(7) "int(11)"
    [1]=> string(7) "int(11)"
    ["Null"]=> string(2) "NO"
    [2]=> string(2) "NO" 
    ["Key"]=> string(3) "PRI" 
    [3]=> string(3) "PRI" 
    ["Default"]=> NULL 
    [4]=> NULL 
    ["Extra"]=> string(0) "" 
    [5]=> string(0) "" 
    } 
    **/

    $field_list[] = $col['Field'];
}

var_dump($field_list);
PHP PDO fetch 模式各种参数的输出结果一览 主要介绍了PHP PDO fetch 模式各种参数的输出结果一览,本文目的是方便根据实际需求选择不同的参数,从而不用一个一个测试过去,需要的朋友可以参考下 立即下载

相关推荐

Vitis开发环境下的双核ARM通信:Hello World背后的AMP架构解析

本文深入解析了Vitis开发环境下ZYNQ双核ARM Cortex-A9处理器的AMP架构与通信机制。通过详细的硬件配置、内存分配和核间通信实现步骤,展示了如何构建高效的双核Hello World系统,为嵌入式系统开发者提供了实用的开发指南和性能优化技巧。

weixin_29162439的博客 218

Medoo数据库基本操作

Medoo查询操作 基本语法: select(表名,字段列表,查询条件) 字段采用数组格式,单字段可使用字符串 查询条件必须采用数组格式 返回数组格式 创建一个公共文件 connect.php ...

wjh-yalta的博客 1093

一文掌握python图形界面开发PyQt6--(一)基本操作、控件、信号与槽、常用控件、布局管理、事件处理、文件对话框

一文掌握python图形界面开发PyQt6--(一)基本操作、控件、信号与槽、常用控件、布局管理、事件处理、文件对话框

qq_38120851的博客 4045

medoo连接mysql_Medoo操作数据库

如果你想更自由的操作数据库,可使用Medoo方式实例化一个数据库,然后再对数据库进行操作建议开发者采用MVC模式,跟数据库相关的操作放在model层,而不是controller调用方法是实例化数据库类以后将db_改为objec->,传入参数参考[函数操作数据](https://www.kancloud.cn/calfbaby/calfbb/419278)~~~$dbconf=\Framewo...

weixin_36380427的博客 443

【CubeMX】STM32G474 HRTIM 互补PWM与死区时间配置实战

本文详细介绍了如何使用STM32CubeMX配置STM32G474的高分辨率定时器HRTIM生成互补PWM波形并精确设置死区时间。通过实战步骤讲解时钟配置、死区计算与高级功能,帮助工程师在电机驱动和电源应用中实现精准控制,避免上下桥臂直通风险。

grpc6streamer的博客 727

银河麒麟V10-ARM架构-postgresql安装与部署指南

本文详细介绍应用源码进行pgsql的安装步骤,本文以postgresql-12.0为例。提示:以下是本篇文章正文内容,下面案例可供参考银河麒麟系统安装程序比较繁琐,潜在问题比较多,个人建议均通过源码自定义编译安装。国产系统还需努力啊!

idols_man的博客 1万+

Medoo查询条件+排序的几个例子

Medoo框架查询指定条件并排序的实例: $database->debug()->select("book", "*", ["ORDER" => ["date" => "DESC"]]); 查询语句:SELECT * FROM `book` ORDER BY `date` DESC $database->debug()-&gt

Avenjan优快云博客 3195

核心面试聚焦:业务问题+系统问题+设计题---字节、阿里、美团等整理统计

业务系统及其他相关面试问题整理:线上相关问题排查+高并发系统的限流+高并发秒杀系统设计+负载均衡+一个网站有 20 亿 url 存在一个黑名单中,这个黑名单要怎么存?若此时随便输入一个 url,你如何快速判断该 url 是否在这个黑名单中?并且需在给定内存空间(比如:500M)内快速判断出?

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 172万+

PHP中mysql框架 medoo

#PHP中mysql框架 medoo。解压后删除其余多余的部分我们只需要保留。这里直接上个目录结构示意图。

加金开发 445

【Ranger】mac下Apache Ranger编译安装

a、编译过程中出现测试用例不通过和文件认证错误错误:带上参数-DskipTests=true -Drat.skip=true 重新编译;b、若编译过程中出现缺少jar包的情况,可能下载不了,需要手动自动添加;c、编译所需的其他工具如maven等安装配置略。采用这个会报错,因此我才用了下面一个命令。初始化设置Ranger Admin:执行。然后进入target目录。

九师兄 2103

55、宇宙微波背景辐射望远镜及其光学系统解析

本文详细解析了宇宙微波背景辐射(CMB)望远镜及其光学系统的设计与优化。内容涵盖折射与反射光学系统的特性、旁瓣控制技术、气球与地面观测系统的对比、探测器阵列的发展、光学系统设计流程以及不同观测场景下的光学系统选择。同时,文章展望了CMB望远镜光学系统的未来发展趋势,包括技术创新、多频段观测、国际合作与大型项目等。通过系统性的分析与对比,为CMB研究提供了全面的技术支持与理论基础。

f9g0h的博客 143

medoo php,pdo-Medoo - 高效的轻量级PHP数据库框架, 提高开发效率!

Raw ObjectMedoo可以使用原始表达式来进行复杂的或自定义的查询,尤其是在使用SQL内置函数的时候.支持占位符号,以防止注入和优化语法.Medoo::raw($query, $map)查询列中使用可以直接在select()中做为字段查出,这时候key值将做为别名使用$data = $database->get('account', ['user_name','user_id','s...

weixin_35135418的博客 564

【YOLO26科研级突破】集成BiFPN双向特征金字塔,让多尺度特征融合效率与精度双跃升

打开确保模型解析器能识别BiFPN模块。通过将BiFPN双向特征金字塔集成到YOLO26中,我们实现了一个“全尺度双向特征流动+加权融合+精准检测”的目标检测模型。这个改进不仅在工程上能大幅提升多尺度、复杂场景下的检测精度,更在科研上提供了“双向特征融合”的创新思路——这种思路可以延伸到其他检测网络(如Faster R-CNN、SSD)的Neck模块改进中,帮你在论文中打造独特的研究点。

LXY_LOVE36的博客 200

Medoo Min的使用:取出被查询字段中的最小值

min方法:min($table, $column $where),接受三个参数的传入 第一个需要传入的参数为字符串:String,即为要查询的数据表名 第二个需要传入的参数为字符串:String,即为要查询的字段名 第三个需要传入的参数为数组:array(),即为查询条件,条件参数可默认不传 返回值为字符串:String,为数字 以下以官网示例进行完整说明(部分可能

PHP开发实践 1354

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

php medoo 创建表,Medoo Query的使用:执行SQL语句

query方法:query($string),接受一个参数,参数类型为字符串:String,即为要执行的SQL语句这个方法比较适合分工比较明确有专属DBA人员,或者实在不会用Medoo自带的方法执行复杂SQL语句的人以下以官网示例进行完整说明(部分可能经过修改)例:$database = new medoo("my_database");$database->query("CREATE TA...

weixin_32014283的博客 384

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Medoo Query的使用:执行SQL语句

query方法:query($string),接受一个参数,参数类型为字符串:String,即为要执行的SQL语句 这个方法比较适合分工比较明确有专属DBA人员,或者实在不会用Medoo自带的方法执行复杂SQL语句的人 以下以官网示例进行完整说明(部分可能经过修改) 例: $database = new medoo("my_database"); $data

PHP开发实践 4875

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

medoo 使用分页_Medoo入门-使用示例

medoo 使用分页In this article I’m going to walk you through Medoo, a lightweight database abstraction library for PHP. Its main features include: 在本文中,我将带您了解Medoo,它是PHP的轻量级数据库抽象库。 其主要功能包括: Support for m...

culi3182的博客 1276

Medoo Select的使用:查询数据

select方法:有两种传参调用方式 1、单表查询:三个参数 select($table, $columns, $where) 第一个参数类型为字符串:String,即为要查询的数据表名 第二个参数类型为字符串或数组:String/Array,即为要查询的字段名称,如果只是一个字段就写字符串:String,如果是要查询所有是“*”的话,也是传入字符串;如果要查多个字段,比如

PHP开发实践 7433

Medoo 微框架的细节小坑

1. insert() 返回值 结论:insert() 、update()、 delete() 三个函数都将会返回一个pdo对象。 使用 Medoo 1.4.5 微框架时,根据中文文档,调用 $database-&amp;gt;insert() 函数时,返回值如下: Return: [number] 返回插入的id 该返回似乎与 1.2 的旧版本一致,但实际返回值不是id, 而是一个PDOS...

ParrySMS 3923

轻量级的PHP数据库框架Medoo

为什么80%的码农都做不了架构师?>>> ...

weixin_34150224的博客 764

Medoo轻量级的数据库框架

Medoo是一个开源超轻量级的 PHP SQL 数据库框架,提供简单,易学,灵活的 API,用于提升开发 Web 应用的效率与性能。 与其它同类的产品相比,Medoo 最大的优势就在于其轻量级(只有一个文件,并且体积只有 8KB 左右),以及配置和 API 都非常简单易用,而且还能支持多种数据库。 在当今 Web 应用后台开发的流程中,与数据库之间的数据交换是极为重要的一环,尤其是 S

亦风的家园 1030

php medoo 创建表,medoo实现数据库基本操作

摘要:

weixin_30673719的博客 364

PHP快速入门 -- PDO

PDO的数据获取方法与其他数据库扩展都非常类似,只要成功执行SELECT查询,都会有结果集对象产生。不管是使用PDO对象中的query()方法,还是使用prepare()和execute()等方法结合的预处理语句,执行SELECT查询都会得到相同的结果集对象PDOStatement。都需要通过PDOStatement类对象中的方法将数据遍历出来。下面介绍PDOStatement类中常见的几个获取结

小波专栏 1002

php中fetchall()与fetch()的区别

fetch是取第一条数据出来,tetchall是取所有。以上!

鱼火 7115

php pdo 数字索引,php中的pdo如何fetch的时候不返回数字索引数组

环境:(PHP 5 >= 5.1.0, PHP 7, PECL pdo >= 0.1.0)PDOStatement::fetch—从结果集中获取下一行说明PDOStatement::fetch ([ int $fetch_style [, int $cursor_orientation = PDO::FETCH_ORI_NEXT [, int $cursor_offset = 0 ...

weixin_36444661的博客 274

php medoo 创建表,PHP数据库框架Medoo1.6安装教程

开始使用Medoo是非常简单的事!Medoo1.2开始不支持PHP5.4或以下,若你使用的是1.2以前的版本,请选择菜单 中文文档(<1.2)要求1、PHP>=5.4, 必须支持PDO2、支持 MySQL, MSSQL, SQLite 等数据库.3、确保php_pdo_xxx (xxx = 数据库类型) 的xxx数据扩展已经正确安装并启用.4、需要懂一些SQL知识.PHP PDO扩展列...

weixin_36322984的博客 155
上一篇: Max Core Frequency 异常显示为-1.80GHz -- Intel-Extreme-Tuning-Utility-Intel-XTU (英特尔 XTU)
下一篇: 微信登录异常的解决思路 redirect_uri域名与后台配置不一致,错误码10003
维生素P
博客等级 码龄9年 14粉丝 32原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值