gpt4 book ai didi

php - 使用 codeigniter 将数据上传到 MsSQL 时使用正确的参数

转载 作者:行者123 更新时间:2023-11-29 11:46:26 24 4
gpt4 key购买 nike

我在使用参数时遇到问题,我想将上传的文件从网页中的文件上传插入到 MsSQL 数据库中。我使用 codeigniter 作为我的框架。

Controller

function upload_gen048()
{

$data['filedate']=$this->input->post('fiil');
//print_r ($data);

$this->load->model('navi_model');
$query = $this->navi_model->upload_gen048($data);

型号 函数 upload_gen048($data) {

$x = explode('.',$data['filedate']);

//print_r ($data);

$qString = "";
$qString .= '[dbo].[gen048upload] '; //STORED PROCEDURE
$qString .= "'" .$data['fiil']."','" .$data['filedate']."'";
echo $qString;

查看

<form  id="upload" name="upload" action="<?php echo base_url(); ?>index.php/welcome/upload_gen048" method="POST" class="form-horizontal" enctype="multipart/form-data" onsubmit="return verify_upload()" >

<input style="border:1px solid" type="text" onfocus="true" name="fiil" id="fiil" value=""size="30" />

<input type="file" name="uploadData" id="uploadData" onChange="fileSelect();" style=""/>

这是我的存储过程,当我独立执行它时它一切正常,但我无法从我的网页插入数据。

ALTER PROCEDURE [dbo].[gen048upload]
(
@fileDate VARCHAR(20)

)

AS BEGIN

SET NOCOUNT ON

declare @sql varchar(8000),@sourceTable varchar(500), @dynamic varchar(8000), @tablesuffix varchar(10)
select @tablesuffix=upper(substring(datename(m,convert(datetime,@fileDate)),1,3))+convert(varchar,year(convert(datetime,@fileDate)))
print @tablesuffix


create table #logs(
i int identity(1,1),
tableName varchar(50),
status varchar(30)
)

set @sourceTable ='gen_048_'+@tablesuffix
insert into #logs(tableName,status) select @sourceTable,'CREATED'
IF NOT EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = @sourceTable)
BEGIN
set @sql = '
CREATE TABLE '+@sourceTable+'
(

最佳答案

function upload_gen048()
{
// Here you make a array, with a key 'filedate'
$data['filedate']=$this->input->post('fiil');
//print_r ($data);

$this->load->model('navi_model');
$query = $this->navi_model->upload_gen048($data);

function upload_gen048($data) {
$x = explode('.',$data['filedate']);
//print_r ($data);
$qString = "";
$qString .= '[dbo].[gen048upload] '; //STORED PROCEDURE

// Here you try to get array key 'fiil', but you haven't set that in your code.
$qString .= "'" .$data['fiil']."','" .$data['filedate']."'";
echo $qString;

删除 $data['fiil'] 并且您的代码应该可以工作。还有 var_dump($data);要准确查看数组中的内容,您会发现 $data['fiil'] 不存在。

关于php - 使用 codeigniter 将数据上传到 MsSQL 时使用正确的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34846142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com