时间:2021-07-01 10:21:17 帮助过:10人阅读
php根据表结构自动生成类属性
$table = $_GET['table'];
$rs = $db->queryAll("SELECT column_name,column_type,column_comment,data_type
FROM information_schema.`COLUMNS` WHERE `TABLE_NAME` LIKE '$table'");
$output = '';
foreach ($rs as $r) {
// 下划线转驼峰
$r['column_name'] = lcfirst(implode('', array_map('ucfirst', explode('_', $r['column_name']))));
$output .=<< /** * {$r['column_comment']} * @var {$r['data_type']} */ public \${$r['column_name']}; EOF; } echo '' . $output . '
';
http://www.bkjia.com/PHPjc/1045888.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1045888.htmlTechArticlephp根据表结构自动生成类属性 php根据表结构自动生成类属性 ?php $table = $_GET['table']; $rs = $db-queryAll(SELECT column_name,column_type,column_comment,data_...