bitsCN.com
网上的都是一些静态的,用CASE WHEN结构实现。所以我写了一个动态的。
SP 代码:
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`sp_row_column_wrap`$$
采用 php+mysql 数据库方式运行的强大网上商店系统,执行效率高速度快,支持多语言,模板和代码分离,轻松创建属于自己的个性化用户界面 v3.5更新: 1).进一步静态化了活动商品. 2).提供了一些重要UFT-8转换文件 3).修复了除了网银在线支付其它支付显示错误的问题. 4).修改了LOGO广告管理,增加LOGO链接后主页LOGO路径错误的问题 5).修改了公告无法发布的问题,可能是打压
0
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_row_column_wrap`(IN $schema_name varchar(64),
IN $table_name varchar(64))
BEGIN
declare cnt int(11);
declare $table_rows int(11);
declare i int(11);
declare j int(11);
declare s int(11);
declare str varchar(255);
-- Get the column number of the table
select count(1) from information_schema.columns where
table_schema=$schema_name and table_name=$table_name into cnt;
-- Get the row number of the table
select table_rows from information_schema.tables where
table_schema = $schema_name and table_name=$table_name into $table_rows;
-- Check whether the table exists or not
drop table if exists test.temp;
create table if not exists test.temp (`1` varchar(255) not null);
-- loop1 start
set i = 0;
loop1:loop
if i = $table_rows-1 then
leave loop1;
end if;
set @stmt1 = concat(’alter table test.temp add `’,i+2,’` varchar(255) not null’);
prepare s1 from @stmt1;
execute s1;
deallocate prepare s1;
set @stmt1 = ’’;
set i = i + 1;
end loop loop1;
-- loop1 end;
set s = 0;
-- loop2 start
loop2:loop
-- leave loop2
if s=cnt then
leave loop2;
end if;
set @stmt2 = concat(’select column_name from information_schema.columns where table_schema="’,$schema_name,
’" and table_name="’,$table_name,’" limit ’,s,’,1 into @temp;’);
prepare s2 from @stmt2;
execute s2;
deallocate prepare s2;
set @stmt2 = ’’;
set j=0;
set str = ’ select ’;
-- Loop3 start
loop3:loop
if j = $table_rows then
leave loop3;
end if;
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号