本文整理汇总了PHP中Software::find_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::find_all方法的具体用法?PHP Software::find_all怎么用?PHP Software::find_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::find_all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$conn = Db::get_connection();
if (isset($_GET['software_name'])) {
$software_factory = new Software();
$softwares = $software_factory->find_all(array('where_clause' => "`name` = '{$conn->escape($_GET['software_name'])}' AND (`name` != 'guidatv' OR `type` = 'macosx')", 'limit' => 1));
if (count($softwares) > 0) {
$this->software = $softwares[0];
$this->software->has_many('software_releases');
// Sort releases
$releases = $this->software->software_releases;
usort($releases, array($releases[0], 'sort_releases'));
$this->software->release = $releases[0];
$this->software->release->has_many('software_artifacts');
// Horrible hack to enable per-software caching.
$_REQUEST['id'] = $this->software->id;
}
} else {
if (isset($_GET['id'])) {
$this->software = new Software();
$this->software->find_by_id($_GET['id']);
$this->software->has_many('software_releases');
// Sort releases
$releases = $this->software->software_releases;
usort($releases, array($releases[0], 'sort_releases'));
$this->software->release = $releases[0];
$this->software->release->has_many('software_artifacts');
} else {
$this->render_error();
}
}
Db::close_connection($conn);
}
示例2: update_versiontracker_ratings
/**
* @fn update_versiontracker_ratings
* @short Action method that updates the VersionTracker ratings for software products.
*/
public function update_versiontracker_ratings()
{
$conn = Db::get_connection();
error_reporting(E_ALL | E_STRICT);
$sw = new Software();
$softwares = $sw->find_all();
foreach ($softwares as $software) {
$software->has_one('version_tracker_entries');
if ($software->version_tracker_entry && $software->version_tracker_entry->vt_id != 0) {
$vt = new VTRatingsParser($software->version_tracker_entry->vt_id);
$vt->parse();
$software->version_tracker_entry->rating = $vt->rating;
$software->version_tracker_entry->save();
}
}
$this->render(NULL);
Db::close_connection($conn);
}
示例3: _init_software
/**
* @fn _init_software
* @short Private method that initializes repetitive members of software product page actions.
*/
private function _init_software()
{
$conn = Db::get_connection();
if (isset($_REQUEST['software_name'])) {
$software_factory = new Software();
$softwares = $software_factory->find_all(array('where_clause' => '`name` = \'' . $conn->escape($_REQUEST['software_name']) . '\' AND `type` = \'' . $conn->escape($_REQUEST['software_type']) . '\'', 'limit' => 1));
if (count($softwares) > 0) {
$this->software = $softwares[0];
} else {
$softwares = $software_factory->find_by_query('SELECT `softwares`.`id` ' . 'FROM `softwares` ' . 'LEFT JOIN `software_typos` ON `softwares`.`id` = `software_typos`.`software_id` ' . 'WHERE `software_typos`.`typo` = \'' . $conn->escape($_REQUEST['software_name']) . '\' ' . 'LIMIT 1');
if (count($softwares) > 0) {
$this->software = $softwares[0];
header(sprintf('Location: http://%s%s', $_SERVER['HTTP_HOST'], $this->software->url_to_detail($_REQUEST['subview'])));
exit;
} else {
HTTP::error(404);
}
}
$_REQUEST['id'] = $this->software->id;
} else {
if (isset($_GET['id'])) {
$this->software = new Software();
if ($this->software->find_by_id($_GET['id']) === FALSE) {
$this->flash(l('No such software product!'), 'error');
$this->redirect_to(array('action' => 'index'));
}
} else {
HTTP::error(404);
}
}
$this->software->has_many('software_releases', array('where_clause' => '`released` = \'1\''));
$releases = $this->software->software_releases;
usort($releases, array($releases[0], 'sort_releases'));
$this->release = $releases[0];
$this->software->software_releases = $releases;
Db::close_connection($conn);
}
示例4: software_downloads
/**
* @fn software_downloads
* @short Action method that shows statistics on software downloads grouped by
* software product.
*/
public function software_downloads()
{
$software_factory = new Software();
$this->softwares = $software_factory->find_all(array('order_by' => '`title` DESC'));
}