我正在开发codeigniter项目,我需要将整个数据库mysql迁移到sql server,因为我在select查询中遇到问题,我可以在sql server中看到圆括号不支持表名,这里是我的codeigniter查询
$this->db->_protect_identifiers=false;
$this->db->select('*')->from('tb_card',false);
$this->db->where('company_id',$this->company_id,FALSE)->get()->row_array();
此选择查询生成以下查询
SELECT * FROM (tb_card) WHERE company_id = 27
你可以看到表名周围有圆括号,我想删除它,有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
终于得到了解决方案 (/system/database/drivers/odbc/odbc_driver.php 在这条路径中需要像这样改变函数
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './components/app/app.component';
import { HomeComponent } from './components/home/home.component';
import { LoginComponent } from './components/login/login.component';
import { MobileComponent } from './components/mobile/mobile.component';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
LoginComponent,
MobileComponent
],
imports: [
CommonModule,
HttpModule,
FormsModule,
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'login', component: LoginComponent },
{ path: 'mobile', component: MobileComponent },
{ path: '**', redirectTo: 'home' }
])
]
})
export class AppModuleShared {
}
答案 1 :(得分:0)
您能否使用简单的$this->db->query($sql)
方法,而不是Active Record。
$result = $this->db->query('SELECT * FROM tb_card WHERE company_id = 27');
printr($this->db->last_query());
printr($result->result());
答案 2 :(得分:0)
如果你想选择*(全部),你可以使用$this->db->get();
例如,就像....
function getcompany($company_id)
{
$this->db->where('company_id',$company_id);
$query = $this->db->get('tb_card');
return $query->result();
}
那些功能会像这样返回
SELECT * FROM 'tb_card' WHERE 'company_id' = $company_id
希望它能回答你的问题。
答案 3 :(得分:-1)
请在表名tb_card
$this->db->_protect_identifiers=false; $this->db->select('*')->from('`tb_card`',false); $this->db->where('company_id',$this->company_id,FALSE)->get()->row_array();