- Posts: 3
- Thank you received: 0
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
class productsViewproducts_detail extends JView {
function MSSQL_single($query) {
$jconfig = new JConfig();
$server = $jconfig->mssql_host;
$username = $jconfig->mssql_username;
$password = $jconfig->mssql_password;
$database = $jconfig->mssql_database;
$sqlconnect = mssql_connect($server, $username, $password) or die("Couldn't connect to MS SQL");
$sqldb = mssql_select_db($database, $sqlconnect) or die("Couldn't open the Database");
$results = mssql_query($query) or die(mssql_get_last_message());
$row = mssql_fetch_object($results);
//$xml = simplexml_load_string($row["xmlResult"]);
mssql_close($sqlconnect);
return $row;
}
public function getSpecificCategoryID($name)
{
$name = str_replace("'", "''", $name);
$sql = "select * from MainFoodCategories where MainCategoryName='".$name."'";
return $this->MSSQL_single($sql);
}
}
Please Log in or Create an account to join the conversation.
case 'tableselect':
// $params[0] = table,column,key
// $params[1] = value
// table: table name to query (support #__ notation)
// column: field name to return
// key: field name to use as selector in where condition
// value: value to use for comparison in the where condition (WHERE key = value)
$arg = explode(",", trim($params[0]));
if (count($arg) == 3)
{
$arg = array_map("trim", $arg);
$value = $params[1];
if ($value != '')
{
//Original Code
/* Perform a DB query
$db = JFactory::getDBO();
$db->setQuery("SELECT `" . $arg[1] . "` FROM `" . $arg[0] . "` WHERE `" . $arg[2] . "`=" . $db->quote($value));
$result = $db->loadResult();
if (isset($result)) { $value = $result; }
*/
//Start of MSSQL query
$db = JFactory::getDBO(); //Kept for the db quote function to remove special characters
$query = "SELECT " . $arg[1] . " FROM " . $arg[0] . " WHERE " . $arg[2] . "=" . $db->quote($value);
$jconfig = new JConfig();
// Collects MSSQL server and login information
$server = $jconfig->mssql_host;
$username = $jconfig->mssql_username;
$password = $jconfig->mssql_password;
$database = $jconfig->mssql_database;
$sqlconnect = mssql_connect($server, $username, $password) or die("Couldn't connect to MS SQL");
$sqldb = mssql_select_db($database, $sqlconnect) or die("Couldn't open the Database");
$results = mssql_query($query) or die(mssql_get_last_message());
$row = mssql_fetch_object($results);
mssql_close($sqlconnect);
if(isset($row->$arg[1]))
{
$value = $row->$arg[1];
}
}
}
break;
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.