function getSectionCategorieModel($sec_id, $cat_id) { $result = $this->connector->query("SELECT * FROM sectioncategorie WHERE `sec_id` = '{$sec_id}' AND `cat_id` = '{$cat_id}'"); $row = $this->connector > fetchArray($result); if ($result = mysql_query($query)) { $sectionCategorie = new SectionCategorie(); $sectionCategorie->setSec_id($row['sec_id']); $sectionCategorie->setCat_id($row['cat_id']); return $sectionCategorie; // while($row) // { // echo $result['fname']; // echo " "; // echo $result['lname']; // echo "<br>"; // echo $result['info']; // echo "<br>"; // echo "<br>"; // } } else { echo mysql_errno($con) . ": " . mysql_error($con) . "\n"; } }
<?php /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); require "minixml/minixml.inc.php"; print "<pre>\n"; $xd = new MiniXMLDoc(); $xd->fromFile("canPos_return.xml"); print "\nStatusCode = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusCode'); print "\ncomment = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/comment'); print "\nstatusMessage = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusMessage'); print "\n\n"; $shipping_fields = array("name", "rate", "shippingDate", "deliveryDate", "deliveryDayOfWeek", "nextDayAM", "packingID"); var_dump(fetchArray($xd, 'eparcel/ratesAndServicesResponse', 'product', $shipping_fields)); print "\n</pre>"; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function fetchArray(&$xmldoc, $path, $tag, $fields) { $response = $xmldoc->getElementByPath($path); $children = $response->getAllChildren(); $count = 0; $array = array(); for ($i = 0; $i < $response->numChildren(); $i++) { if ($tag == $children[$i]->name()) { foreach ($fields as $field) { $name = $children[$i]->getElement($field); $array[$count][$field] = $name->getValue(); } $count++; } }
function _xmlToQuote() { $xd = new MiniXMLDoc($this->xml_response); $startTag = 'eparcel/error/'; $this->statusCode = fetchValue($xd, $startTag . 'statusCode'); if ($this->statusCode != "") { $this->error = true; $this->error_msg = fetchValue($xd, $startTag . 'statusMessage'); } else { $this->error = false; $startTag = 'eparcel/ratesAndServicesResponse/'; $this->shipping_comment = fetchValue($xd, $startTag . 'comment'); $shipping_fields = array("name", "rate", "shippingDate", "deliveryDate", "deliveryDayOfWeek", "nextDayAM", "packingID"); $this->shipping_methods = fetchArray($xd, $startTag, 'product', $shipping_fields); } }
<?php require_once dirname(__FILE__) . '/../inc/init.php'; // set timezone to the same as gridwatch's date_default_timezone_set('GMT'); $lastTimes = fetchArray(query("SELECT timestamp FROM wind_vs_demand ORDER BY timestamp DESC LIMIT 1")); $startTime = strtotime($lastTimes[0]); $endTime = time(); if ($endTime - $startTime < 60 * 5) { echo 'up to date'; return; } $remoteFile = 'http://www.gridwatch.templar.co.uk/do_download.php'; $fields = array('none' => 'off', 'demand' => 'on', 'frequency' => 'off', 'coal' => 'off', 'nuclear' => 'off', 'ccgt' => 'off', 'wind' => 'on', 'pumped' => 'off', 'hydro' => 'off', 'other' => 'off', 'oil' => 'off', 'ocgt' => 'off', 'french_ict' => 'off', 'dutch_ict' => 'off', 'irish_ict' => 'off', 'ew_ict' => 'off', 'all' => 'off', 'starthour' => date('G', $startTime), 'startminute' => date('i', $startTime), 'startday' => date('j', $startTime), 'startmonth' => date('n', $startTime) - 1, 'startyear' => date('Y', $startTime), 'endhour' => date('G', $endTime), 'endminute' => date('i', $endTime), 'endday' => date('j', $endTime), 'endmonth' => date('n', $endTime) - 1, 'endyear' => date('Y', $endTime)); $data = curl_init($remoteFile); curl_setopt($data, CURLOPT_POSTFIELDS, $fields); curl_setopt($data, CURLOPT_RETURNTRANSFER, true); curl_setopt($data, CURLOPT_FOLLOWLOCATION, true); curl_setopt($data, CURLOPT_ENCODING, ""); $csv = curl_exec($data); curl_close($data); // Do it $lines = explode("\n", $csv); $head = str_getcsv(array_shift($lines)); $head = array_map('trim', $head); $data = array(); foreach ($lines as $line) { if ($line) { $data[] = array_combine($head, array_map('trim', str_getcsv($line))); } }
function demo() { print "<pre>\n"; $xd = new MiniXMLDoc(); $xd->fromFile("canPos_return.xml"); print "\nStatusCode = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusCode'); print "\ncomment = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/comment'); print "\nstatusMessage = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusMessage'); print "\n\n"; $shipping_fields = array("name", "rate", "shippingDate", "deliveryDate", "deliveryDayOfWeek", "nextDayAM", "packingID"); var_dump(fetchArray($xd, 'eparcel/ratesAndServicesResponse', 'product', $shipping_fields)); print "\n</pre>"; }