请问,当我想加入并处理2个查询时,有人可以帮我修复将数据显示为数组的代码吗?
这是我的控制器:
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function ($extKey) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:extKeyHere/Configuration/TypoScript/setup.ts">');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptConstants('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:extKeyHere/Configuration/TypoScript/constants.ts">');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.' . $extKey,
'Integration',
array(
'Integration' => 'integration',
),
// non-cacheable actions
array(
'Integration' => 'integration',
)
);
},
$_EXTKEY
);
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\SignalSlot\Dispatcher');
$signalSlotDispatcher->connect(
'In2code\Powermail\Controller\FormController', // namespace of Class: In2code\Powermail\Controller
'createActionAfterMailDbSaved',
'Typo3\extName\Controller\IntegrationController', //namespace of Class: Typo3\extName\Controller
'integration',
FALSE);
?>
这是我的模特:
public function pegawai()
{
$data['pegawai'] = $this->Ajax_model->pegawai_get();
$this->load->view('ajax/pegawai', $data);
}
但是我的数据看起来像这样:
//get modal search data
public function pegawai_get($pegawai_id = TRUE)
{
$this->db->select('m_riwayat_kepangkatan.*, m_pegawai.nip, m_pegawai.nama, r_golongan.golongan, r_golongan.jenis_pangkat');
$this->db->from('m_riwayat_kepangkatan');
$this->db->join('m_pegawai', 'm_pegawai.id = m_riwayat_kepangkatan.pegawai_id');
$this->db->join('r_golongan', 'r_golongan.id = m_riwayat_kepangkatan.golongan_id');
$this->db->order_by("pegawai_id", "asc");
$query1 = $this->db->get();
return $query1->result_array();
$this->db->select('m_riwayat_jabatan.*, m_pegawai.nip, m_pegawai.nama, m_opd.nama_opd, m_unit_kerja.unit_kerja');
$this->db->from('m_riwayat_jabatan');
$this->db->where("m_pegawai.id ='$pegawai_id'");
$this->db->join('m_pegawai', 'm_pegawai.id = m_riwayat_jabatan.pegawai_id');
$this->db->join('m_opd', 'm_opd.id = m_riwayat_jabatan.opd_id');
$this->db->join('m_unit_kerja', 'm_unit_kerja.id = m_riwayat_jabatan.unit_kerja_id');
$this->db->order_by("pegawai_id", "asc");
$query2 = $this->db->get();
foreach ($query2->result_array() as $row2){
//$pegawai_id = $row2["pegawai_id"];
//$nip = $row2["nip"];
//$nama = $row2["nama"];
$nama_opd = $row2["nama_opd"];
$unit_kerja = $row2["unit_kerja"];
}
return $query2->result_array();
}
它仅显示为query1的值。我也想为query2内部数据赋值,例如“ nama_opd”和“ unit_kerja”。看起来我缺少了一些东西。
答案 0 :(得分:0)
看看return $query1->result_array();
。您已在第二次查询之前将其返回