本文整理汇总了PHP中Stock::find_by_query方法的典型用法代码示例。如果您正苦于以下问题:PHP Stock::find_by_query方法的具体用法?PHP Stock::find_by_query怎么用?PHP Stock::find_by_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stock
的用法示例。
在下文中一共展示了Stock::find_by_query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preferiti
/**
* @fn preferiti
* @short Lists favorite instruments
* @details Action to list favorite instruments for the current user,
* filtered by attributes like market, type, currency, and sorted by any of
* the columns (defaults to <code>title</code>).
*/
public function preferiti()
{
$conn = $this->get_connection();
$stock_factory = new Stock();
$query = 'SELECT * FROM `creso_titoli` LEFT JOIN `creso_preferiti` ON `creso_titoli`.`isin` = `creso_preferiti`.`isin` ' . "WHERE " . (is_numeric($_REQUEST['attivo']) ? "`attivo` = {$conn->escape($_REQUEST['attivo'])} " : '`attivo` = 1 ') . "AND `utente` = '{$conn->escape($_COOKIE['username'])}' " . (!empty($_REQUEST['mercato']) ? "AND `mercato` = '{$conn->escape($_REQUEST['mercato'])}' " : '') . (!empty($_REQUEST['tipo']) ? "AND `tipo` = '{$conn->escape($_REQUEST['tipo'])}' " : '') . (!empty($_REQUEST['divisa']) ? "AND `divisa` = '{$conn->escape($_REQUEST['divisa'])}' " : '') . "ORDER BY `{$conn->escape($this->get_sort('title'))}` {$conn->escape($this->get_dir())} " . "LIMIT {$conn->escape($this->get_start())}, {$conn->escape($this->get_limit())}";
$this->stocks = $stock_factory->find_by_query($query);
$query = 'SELECT COUNT(*) FROM `creso_titoli` LEFT JOIN `creso_preferiti` ON `creso_titoli`.`isin` = `creso_preferiti`.`isin` ' . "WHERE " . (is_numeric($_REQUEST['attivo']) ? "`attivo` = {$conn->escape($_REQUEST['attivo'])} " : '`attivo` = 1 ') . "AND `utente` = '{$conn->escape($_COOKIE['username'])}' " . (!empty($_REQUEST['mercato']) ? "AND `mercato` = '{$conn->escape($_REQUEST['mercato'])}' " : '') . (!empty($_REQUEST['tipo']) ? "AND `tipo` = '{$conn->escape($_REQUEST['tipo'])}' " : '') . (!empty($_REQUEST['divisa']) ? "AND `divisa` = '{$conn->escape($_REQUEST['divisa'])}' " : '');
$conn->prepare($query);
$conn->exec();
$this->count = $conn->fetch_array()[0];
$conn->free_result();
$this->is_favorite = TRUE;
$this->render(array('action' => 'index'));
}
示例2: run
public function run($context)
{
$stock_factory = new Stock();
$stocks = $stock_factory->find_by_query('SELECT * FROM `creso_titoli` ' . 'LEFT JOIN `creso_obbligazioni` ON `creso_titoli`.`isin` = `creso_obbligazioni`.`isin` ' . 'WHERE ' . "`creso_titoli`.`tipo` = 'obbligazione' " . 'AND ' . "`creso_obbligazioni`.`emissione` = '0000-00-00' " . 'AND ' . '`creso_titoli`.`attivo` = 1 ' . 'LIMIT 1500');
$updated_count = 0;
foreach ($stocks as $stock) {
$bond = new Bond();
$bond->find_by_id($stock->isin);
$bond->emissione = isin2emissione_ariva($stock->isin);
if ($bond->emissione != '0000-00-00') {
$bond->save();
$updated_count++;
}
}
printf("%s updated %d bonds\n", get_called_class(), $updated_count);
}
示例3: ensure_multiple_isin
protected function ensure_multiple_isin()
{
$isins_from_request = isset($_REQUEST['id']) ? $_REQUEST['id'] : $_REQUEST['isin'];
if (isset($isins_from_request)) {
$isins = explode(',', $isins_from_request);
} else {
$conn = Db::get_connection();
$stock_factory = new Stock();
// $stocks = $stock_factory->find_all(array(
// 'where_clause' => "`tipo` = 'obbligazione' " .
// 'AND `attivo` = 1',
// 'order_by' => '`title` ASC',
// 'limit' => 57,
// 'start' => 0
// ));
if (!isset($_REQUEST['start'])) {
$_REQUEST['start'] = 0;
}
$stocks = $stock_factory->find_by_query('SELECT `creso_titoli`.`isin` FROM `creso_titoli` ' . 'JOIN `creso_obbligazioni` ON `creso_titoli`.`isin` = `creso_obbligazioni`.`isin` ' . "WHERE `creso_titoli`.`tipo` = 'obbligazione' " . 'AND `creso_titoli`.`attivo` = 1 ' . 'AND `creso_obbligazioni`.`zero_coupon` = 0 ' . 'ORDER BY ' . '`creso_obbligazioni`.`tasso` DESC ' . ',' . '`creso_obbligazioni`.`scadenza` DESC ' . "LIMIT {$conn->escape($_REQUEST['start'])}, 170");
$isins = array_map(function ($stock) {
return $stock->isin;
}, $stocks);
Db::close_connection($conn);
// $this->redirect_to(array('action' => 'compare', 'id' => implode(',', $isins)));
}
$this->isins = $isins;
}
示例4: dirname
<?php
ini_set('max_execution_time', 3000);
require_once dirname(__FILE__) . "/lib.inc.php";
require_once dirname(__FILE__) . "/../include/db.inc.php";
require_once dirname(__FILE__) . "/../include/" . DB_ADAPTER . "_adapter.php";
require_once dirname(__FILE__) . "/../models/preference.php";
require_once dirname(__FILE__) . "/../models/bond.php";
require_once dirname(__FILE__) . "/../models/stock.php";
date_default_timezone_set('Europe/Rome');
echo "Reading preferences...";
$preference_factory = new Preference();
$preferences = $preference_factory->find_all()[0];
// print_r($preferences);
echo "done\n";
$stock_factory = new Stock();
$stocks = $stock_factory->find_by_query('SELECT * FROM `creso_titoli` ' . 'LEFT JOIN `creso_obbligazioni` ON `creso_titoli`.`isin` = `creso_obbligazioni`.`isin` ' . 'WHERE ' . "`creso_titoli`.`tipo` = 'obbligazione' " . 'AND ' . "`creso_obbligazioni`.`emissione` = '0000-00-00' " . 'AND ' . '`creso_titoli`.`attivo` = 1 ' . 'LIMIT 1500');
printf("%d bonds found\n", count($stocks));
$updated_count = 0;
foreach ($stocks as $stock) {
// print_r($stock);
$bond = new Bond();
$bond->find_by_id($stock->isin);
// print_r($bond);
$bond->emissione = isin2emissione_ariva($stock->isin);
print_r($bond);
if ($bond->emissione != '0000-00-00') {
$bond->save();
$updated_count++;
}
}
printf("%d updated bonds\n", $updated_count);