phpfusion
Your ColdFusion like clone for PHP
phpfusion official homepage CFML (ColdFusion Markup Language)
![[cml_media_alt id='4345']phpfusion-logo-1024[/cml_media_alt]](https://www.flagsoft.com/cmswp/wp-content/uploads/2017/11/phpfusion-logo-1024-150x150.jpeg)
Online Demo
http://www.flagsoft.com/phpfusion/index.php
Installation and Setup
Overview
- Download phpfusion from GitHub https://github.com/flagsoft/phpfusion (Use green button "clone or download" and choose "Download ZIP" or "Open in Desktop" or just clone it or whatever
- Unzip to a new empty folder if you downloaded the ZIP package
- Setup and install Database and tables, see file example_catalogue_phpfusion.sql (MySQL) for more details. Basic DB setup
- Just adjust database username and database password in your phpfusion files (see .php files)
- Done!
Database (Example)
There is nothing special here. There a are no extra fancy files required. Just normal tables.
-- phpMyAdmin SQL Dump -- version 3.2.4 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jan 23, 2012 at 04:21 PM -- Server version: 5.1.44 -- PHP Version: 5.3.1 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `phpfusion` -- -- -------------------------------------------------------- -- -- Table structure for table `catalogue` -- CREATE TABLE IF NOT EXISTS `catalogue` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `size` int(11) DEFAULT NULL, `carbrand` varchar(40) CHARACTER SET latin1 COLLATE latin1_general_cs DEFAULT NULL, `carname` varchar(40) CHARACTER SET latin1 COLLATE latin1_general_cs DEFAULT NULL, `consumption` float NOT NULL, `ps` int(11) NOT NULL, `greenlabel` varchar(6) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Dumping data for table `catalogue` -- INSERT INTO `catalogue` (`id`, `size`, `carbrand`, `carname`, `consumption`, `ps`, `greenlabel`) VALUES (1, 4, 'Volvo', 'Abc', 5.1, 200, 'A'), (2, 2, 'BMW', 'i5', 10, 250, 'B'), (3, 6, 'Volkswagen', 'VW Bus', 8.1, 120, 'B'), (4, 4, 'Bulgati', 'BT2', 10.2, 1000, 'C'); -- -------------------------------------------------------- -- -- Table structure for table `description` -- CREATE TABLE IF NOT EXISTS `description` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `lang` text NOT NULL, `desc` text CHARACTER SET latin1 COLLATE latin1_general_cs, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `description` -- INSERT INTO `description` (`id`, `lang`, `desc`) VALUES (1, 'EN', 'This is your Catalogue description. Here you can search for cars.'), (2, 'DE', 'Dies ist Ihre Katalog Beschreibung in Deutsch.');
Connect to the Database (MySQL)
include_once("pf_core.php")
Include the phpfusion core.
PF_DB_connect()
Connect to database.
PF_DB_select()
Selects a database.
PF_DB_table()
Selects a table.
Example code:
<?
include_once("pf_core.php");
PF_DB_connect("localhost", "<your-database-name>", "<your-database-password>");
PF_DB_select("<your-database-name>");
PF_DB_table("catalogue");
Controller
File index.php
It's a kind of a controller 😉
include("user_config.php");
[...]
<script src="pf_util.js" type="text/javascript"></script>
<link href="pf_style.css" rel="stylesheet" type="text/css" />
[...]
include($g_USER_headerfile);
[...]
include($g_USER_menufile);
if ( isset($_GET['contact']) ) {
include($g_USER_contactfile);
} else if ( isset($_GET['search']) ) {
include("cat_searchresult.php");
} else {
include("index_txt.html");
}
[...]
include($g_USER_footerfile);
Misc
PF_setLANG()
Set language id.
PF_query()
Query database
#identifier#
Insert values from database
Example Code:
<? PF_DB_table("description"); ?>
<? PF_setLANG("EN"); ?>
<? echo "Current Language: " . ${g_USER_LANG}; ?>
<? PF_query("SELECT * FROM description WHERE lang='${g_USER_LANG}'", NULL); ?>
<!-- show the description out of database -->
<div style="background-color:#eeeeee">#desc#</div>
Output:
Current Language: EN
This is your Catalogue description. Here you can search for cars.
NOTE: See also "description" table within database.
Show table results with options
PF_HTML_checkbox_to_SQL()
Create SQL for checkbox
PF_HTML_radio_option_to_SQL()
Create SQL for radio option
PF_CSV_to_HTML_table()
Print html table.
NOTE: You can connect to an other phpfusion file, here "Details", to show detail record. This is down with cat_detail.php?id=
Example Code:
<? PF_DB_table("catalogue"); ?>
<?
$g_SQL_fields = ""
. PF_HTML_checkbox_to_SQL("greenlabel")
. PF_HTML_radio_option_to_SQL("ps")
. PF_HTML_radio_option_to_SQL("size")
. PF_HTML_radio_option_to_SQL("consumption")
;
$g_sql = "SELECT * FROM "
. " $g_DB_table "
. " WHERE (1) "
. $g_SQL_fields
;
//PF_debug(true);
//PF_debug(false);
$result = mysql_query($g_sql);
PF_CSV_to_HTML_table($g_sql, "Detail", "cat_detail.php?id=");
![[cml_media_alt id='4340']phpfusion-Screen Shot 2017-11-14 at 15.11.55[/cml_media_alt]](https://www.flagsoft.com/cmswp/wp-content/uploads/2017/11/phpfusion-Screen-Shot-2017-11-14-at-15.11.55.png)
![[cml_media_alt id='4341']phpfusion-Screen Shot 2017-11-14 at 15.12.05[/cml_media_alt]](https://www.flagsoft.com/cmswp/wp-content/uploads/2017/11/phpfusion-Screen-Shot-2017-11-14-at-15.12.05.png)
cat_detail.php
<?
include_once("pf_core.php");
PF_DB_connect("localhost", "<your-db-name>", "<your-db-password>");
PF_DB_select("<your-db-name>");
PF_DB_table("catalogue");
$ID=$_GET['id'];
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="pf_style.css" />
<!-- <link rel="stylesheet" type="text/css" href="car_detail.css" /> -->
</head>
<body>
<a href="index.html">Search</a>
<h2>Catalogue Detail</h2>
<? PF_query("SELECT * FROM catalogue WHERE id=$ID", NULL); ?>
<table class="detail">
<tr>
<td>Id:</td>
<td>#id#</td>
</tr>
<tr>
<td>Number of Seats:</td>
<td>#size#</td>
</tr>
<tr>
<td>Car Brand:</td>
<td>#carbrand#</td>
</tr>
<tr>
<td>Consumption:</td>
<td>#consumption#</td>
</tr>
<tr>
<td>Green Label:</td>
<td>#greenlabel#</td>
</tr>
</table>
</body>
</html>
<? PF_DB_close(); ?>
<? ob_end_flush(); ?>
PF_use_template()
You can use template files which get interpreted for CFML ColdFusion Markup Language.
CFML (ColdFusion Markup Language)
cfoutput
Input:
<cfoutput>Welcome to PhpFusion, seriously.</cfoutput>
Output:
<cfset variable_hello = "PHP"> <cfoutput>Hi #variable_hello#!</cfoutput>
Output:
cfset
Input:
<cfset variable_hello = "Hallo Welt!"> <cfoutput>Hi! #variable_hello#</cfoutput>
Output:
cfloop (DRAFT)
<table border="4">
<cfloop query="getMyFriends">
<tr>
<td>#id#</td>
<td>#carbrand#</td>
</tr>
</cfloop>
</table>
cfif, cfelseif, cfelse (not working right now?)
<cfif expression>
if....
<cfelseif expression>
else if....
<cfelse>
else...
</cfif>
Create CSV tables
PF_CSV_to_HTML_table()
Example code:
$result = mysql_query($g_sql);
PF_CSV_to_HTML_table($g_sql, "Detail", "cat_detail.php?id=");
echo "<pre>";
while($row = mysql_fetch_array($result)) {
echo '<a href=' . "cat_detail.php?id=" . $row['id'] . ">Detail</a>";
echo
$row['id'] . "; " .
$row['carbrand'] . "; " .
$row['carname'] . "; " .
$row['size'] . "; " .
$row['consumption'] . "; " .
$row['ps'] . "; " .
$row['greenlabel'];
echo "<br/>";
}
echo "</pre>";
Output:
"1", "Volvo", "Abc", "4", "5.1", "200", "A" "2", "BMW", "i5", "2", "10", "250", "B" "3", "Volkswagen", "VW Bus", "6", "8.1", "120", "B" "4", "Bulgati", "BT2", "4", "10.2", "1000", "C"















