本文整理汇总了PHP中Software::find_by_query方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::find_by_query方法的具体用法?PHP Software::find_by_query怎么用?PHP Software::find_by_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::find_by_query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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);
}