Javascript 如何将php文件转换为codeigniter
我需要帮助将这段代码转换为codeigniter MVC,我有3个文件php Openlink3.php用于viewer class.php用于class,databaseConnection.php用于model 我无法将此php文件转换为codeigniter。请帮帮我 这是我的PHP代码Openlink.PHPJavascript 如何将php文件转换为codeigniter,javascript,php,mysql,codeigniter,pervasive-sql,Javascript,Php,Mysql,Codeigniter,Pervasive Sql,我需要帮助将这段代码转换为codeigniter MVC,我有3个文件php Openlink3.php用于viewer class.php用于class,databaseConnection.php用于model 我无法将此php文件转换为codeigniter。请帮帮我 这是我的PHP代码Openlink.PHP “,”)> 简单的步骤,你必须遵循,你可以需要检查用户指南第一,无论如何试试这个 您必须遵循以下步骤: 步骤1:用于数据库连接 在database.php中 在$db['def
“,”)>
简单的步骤,你必须遵循,你可以需要检查用户指南第一,无论如何试试这个
您必须遵循以下步骤:
步骤1:用于数据库连接
在database.php中
在$db['default']
使用autoload.php加载数据库
$autoload['libraries'] = array('database');
步骤2:
创建模型示例Mdl_mis.php
$autoload['libraries'] = array('database');
例如:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mdl_mis extends CI_Model {
function getAllApplink(){
$this->db->select("SELECT a.RAL_Code,a.RAL_App_Name,a.RAL_Remarks,b.RAL_APPIconLocation,b.RAL_ApplicationLink");
$this->db->from("R_Application_List as a");
$this->db->join("R_Application_Links as b","a.RAL_Code=b.RAL_APPCODE",'INNER');
$this->db->where("a.RSC_Active",1);
$result = $this->db->get()->result_array();
return $result;
}
function getAppLink($appCode,$user){
$this->db->select("*");
$this->db->from("R_Application_Links");
$this->db->where("RAL_APPCode",$appCode);
$result = $this->db->get()->row_array();
$a = $result['RAL_APPCode'];
$b = $result['RAL_InstallationLink'];
$link = $result['RAL_ApplicationLink'];
$d = $result['RAL_APPIconLocation'];
$linktoOpen = $link.$user.$appCode;
return trim($link);
}
}
?>
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MisApplication extends CI_Controller {
public function index()
{
/* Load you model first */
$this->load->model('Mdl_mis');
$data['all_link'] = $this->Mdl_mis->getAllApplink();
/* Create one view called index.php and load it and pass your data*/
$this->load->view('index',$data);
}
}
?>
步骤4:将代码放入index.php
视图
<!DOCTYPE html>
<html>
<body>
<table align=center cellpadding=10>";
<tr height=120>";
<?php
$appcount=0;
foreach($all_link as $rs))
{
$appcode = $rs["RAL_Code"];
$appname = $rs["RAL_App_Name"];
$desc = $rs["RAL_Remarks"];
$icon = $rs["RAL_APPIconLocation"];
$applink = trim($rs["RAL_ApplicationLink"]);
if($appcount==3){
echo "<tr height=120>";
//echo "<td>";
$appcount=0;
}
//echo "<td>".$appcode."</td>";
//echo "<td>".$appname."</td>";
echo "<td valign=bottom><img src=".$icon."height=30 width=150 onclick='openApp(\"$appcode\",\"$user\",\"$applink\");' </img></td>";
//echo "<td><input type=\"button\" ></td>"
//echo "<td>".$desc."</td>";
echo '<script>openApp();</script>';
$appcount++;
}
echo "</table>";
?>
<img src="dtr.png" height="30" width="150" onclick=openApp("0001","<?php echo $user; ?>","<?php echo $appLink = $this->Mdl_mis->getAppLink("0001",$user); ?>") ></img></br>
<input type="button" id="btn.DTR"; name="btn.Dtr"; value="DTR"; onclick='openApp("0001","<?php echo $user; ?>","<?php echo $appLink = $this->Mdl_mis->getAppLink("0001",$user); ?>")'/>
<input type="button" id="jose"; name="btn.OpenApp"; value="Approval System(test)"; background="dtr.png";onclick='openApp("0014","<?php echo $user; ?>","<?php echo $appLink = $this->Mdl_mis->getAppLink("0002",$user); ?>")'/>
<script language="javascript">
function openApp(Appcode, User, link){
var OpenLink;
OpenLink = link+"?A1="+User+"&A2="+Appcode; // Concatenating strings
//alert(OpenLink);
//document.write (OpenLink); // printing the Concatenated string
//window.open(OpenLink);
//window.open(OpenLink,'_blank', 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10000, top=10000, width=10, height=10, visible=none', '');
window.location.href = OpenLink;
}
</script>
</html>
";
";
简单的步骤,你必须遵循,你可以需要检查用户指南第一,无论如何试试这个
您必须遵循以下步骤:
步骤1:用于数据库连接
在database.php中
在$db['default']
使用autoload.php加载数据库
$autoload['libraries'] = array('database');
步骤2:
创建模型示例Mdl_mis.php
$autoload['libraries'] = array('database');
例如:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mdl_mis extends CI_Model {
function getAllApplink(){
$this->db->select("SELECT a.RAL_Code,a.RAL_App_Name,a.RAL_Remarks,b.RAL_APPIconLocation,b.RAL_ApplicationLink");
$this->db->from("R_Application_List as a");
$this->db->join("R_Application_Links as b","a.RAL_Code=b.RAL_APPCODE",'INNER');
$this->db->where("a.RSC_Active",1);
$result = $this->db->get()->result_array();
return $result;
}
function getAppLink($appCode,$user){
$this->db->select("*");
$this->db->from("R_Application_Links");
$this->db->where("RAL_APPCode",$appCode);
$result = $this->db->get()->row_array();
$a = $result['RAL_APPCode'];
$b = $result['RAL_InstallationLink'];
$link = $result['RAL_ApplicationLink'];
$d = $result['RAL_APPIconLocation'];
$linktoOpen = $link.$user.$appCode;
return trim($link);
}
}
?>
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MisApplication extends CI_Controller {
public function index()
{
/* Load you model first */
$this->load->model('Mdl_mis');
$data['all_link'] = $this->Mdl_mis->getAllApplink();
/* Create one view called index.php and load it and pass your data*/
$this->load->view('index',$data);
}
}
?>
步骤4:将代码放入index.php
视图
<!DOCTYPE html>
<html>
<body>
<table align=center cellpadding=10>";
<tr height=120>";
<?php
$appcount=0;
foreach($all_link as $rs))
{
$appcode = $rs["RAL_Code"];
$appname = $rs["RAL_App_Name"];
$desc = $rs["RAL_Remarks"];
$icon = $rs["RAL_APPIconLocation"];
$applink = trim($rs["RAL_ApplicationLink"]);
if($appcount==3){
echo "<tr height=120>";
//echo "<td>";
$appcount=0;
}
//echo "<td>".$appcode."</td>";
//echo "<td>".$appname."</td>";
echo "<td valign=bottom><img src=".$icon."height=30 width=150 onclick='openApp(\"$appcode\",\"$user\",\"$applink\");' </img></td>";
//echo "<td><input type=\"button\" ></td>"
//echo "<td>".$desc."</td>";
echo '<script>openApp();</script>';
$appcount++;
}
echo "</table>";
?>
<img src="dtr.png" height="30" width="150" onclick=openApp("0001","<?php echo $user; ?>","<?php echo $appLink = $this->Mdl_mis->getAppLink("0001",$user); ?>") ></img></br>
<input type="button" id="btn.DTR"; name="btn.Dtr"; value="DTR"; onclick='openApp("0001","<?php echo $user; ?>","<?php echo $appLink = $this->Mdl_mis->getAppLink("0001",$user); ?>")'/>
<input type="button" id="jose"; name="btn.OpenApp"; value="Approval System(test)"; background="dtr.png";onclick='openApp("0014","<?php echo $user; ?>","<?php echo $appLink = $this->Mdl_mis->getAppLink("0002",$user); ?>")'/>
<script language="javascript">
function openApp(Appcode, User, link){
var OpenLink;
OpenLink = link+"?A1="+User+"&A2="+Appcode; // Concatenating strings
//alert(OpenLink);
//document.write (OpenLink); // printing the Concatenated string
//window.open(OpenLink);
//window.open(OpenLink,'_blank', 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10000, top=10000, width=10, height=10, visible=none', '');
window.location.href = OpenLink;
}
</script>
</html>
";
";
检查Codeigniter用户指南您正在使用哪个数据库?检查Codeigniter用户指南您正在使用哪个数据库?