本文整理匯總了PHP中Currency::setCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Currency::setCode方法的具體用法?PHP Currency::setCode怎麽用?PHP Currency::setCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Currency
的用法示例。
在下文中一共展示了Currency::setCode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addToCollection
protected function addToCollection($currencyParams, $currencyCollection)
{
$currencyObj = new Currency();
$currencyObj->setSource($currencyParams['source']);
$currencyObj->setType($currencyParams['type']);
$currencyObj->setCode($currencyParams['code']);
$currencyObj->setName($currencyParams['name']);
$currencyObj->setPrice(floatval(str_replace(',', '.', $currencyParams['price'])));
$currencyCollection->add($currencyObj);
}
示例2: readUnits
public function readUnits()
{
$con = self::openConnection();
$currencies = new Currencies();
mysqli_begin_transaction($con);
$sql = "SELECT * FROM currency WHERE 1";
$res = mysqli_query($con, $sql);
while ($arrRes = mysqli_fetch_assoc($res)) {
$currency = new Currency();
$currency->setId($arrRes['id']);
$currency->setCode($arrRes['code']);
$currencies->setUnit($currency);
}
return $currencies;
}
示例3: getCurrencies
protected function getCurrencies()
{
$wikipedia = $this->web->get(sfConfig::get('app_source_currencies'), null, array('User-Agent' => 'Steve Lacey <steve@stevelacey.net>', 'Cache-Control' => 'no-cache'));
$xml = new SimpleXMLElement($wikipedia->getResponseText());
$article = $xml->page->revision->text;
$table = substr($article, strpos($article, '{|'), strpos($article, '|}') - strpos($article, '{|'));
foreach (explode('-| ', str_replace(array('[', ']', "\n"), '', $table)) as $row) {
$row = explode(' || ', trim($row, '| '));
if (isset($row[2], $row[4]) && is_numeric($row[2])) {
$currency = new Currency();
$currency->setCode(sfConfig::get('app_currency_alias_' . $row[0], $row[0]));
$currency->setNumber($row[1]);
$currency->setDigits(ceil($row[2]));
$currency->setName($row[3]);
$currency->save();
}
}
}
示例4: parseCurrencies
public function parseCurrencies()
{
$currencies = new Currencies();
$keyParams = array();
foreach ($this->xmlProducts as $product) {
$cur = $product->getCurrency();
if (!empty($cur) && !in_array($cur, $keyParams)) {
array_push($keyParams, $cur);
$currency = new Currency();
$currency->setCode($cur);
$currencies->setUnit($currency);
}
}
$currencyDAO = new CurrencyDAO();
$currencyDAO->insertUnits($currencies);
$currencies = $currencyDAO->readUnits();
return $currencies;
}