很多站长朋友们都不太清楚咋样php导出sql,今天小编就来给大家整理咋样php导出sql,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 php 中SQL怎导入和导出的?? 2、 php 导出 字段 内容 为sql文件 3、 怎么通过php把sql数据的数据导出的表格 php 中SQL怎导入和导出的??上传phpmyadmin,然后用你的数据库帐号和密码登录,进去后,即有导出导入操作。
php 导出 字段 内容 为sql文件phpmyadmin 导出的时候选一下另存为_DB_文件 ,导出来的就是.sql文件了
怎么通过php把sql数据的数据导出的表格使用phpexcel插件。
<?php
/**
* erport
* 导出excel
*/
$dir = dirname ( __FILE__ );
require $dir . '/Class/db.class.php';
require $dir . '/PHPExcel/PHPExcel.php';
$dbObj = new db ();
$phpexcelObj = new PHPExcel ();
for($i = 1; $i <= 3; $i ++) {
$what = "*";
$condition = "student where grade = " . $i . " ORDER BY score DESC";
$res = $dbObj->mySelect ( $what, $condition );
if ($i > 1) {
$phpexcelObj->createSheet ();
}
$phpexcelObj->setActiveSheetIndex ( $i - 1 );
$sheetObj = $phpexcelObj->getActiveSheet ( $i );
$sheetObj->setTitle ( $i . "年级" );
$sheetObj->setCellValue ( 'A1', 'name' )->setCellValue ( 'B1', 'score' )->setCellValue ( 'C1', 'class' );
$j = 2;
foreach ( $res as $key => $val ) {
$sheetObj->setCellValue ( 'A' . $j, $res [$key] ['name'] )->setCellValue ( 'B' . $j, $res [$key] ['score'] )->setCellValue ( 'C' . $j, $res [$key] ['class'] );
$j ++;
}
}
$phpexcelObj->setActiveSheetIndex ( 1 );
$writerObj = PHPExcel_IOFactory::createWriter ( $phpexcelObj, 'Excel5' );
$writerObj->save ( $dir . '/Excels/scores.xls' );
关于咋样php导出sql的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于咋样php导出sql phpstudy怎么导出数据库的详细内容...