本文整理汇总了PHP中Error::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::generate方法的具体用法?PHP Error::generate怎么用?PHP Error::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
function load()
{
if ($this->code) {
$res = db_query("SELECT * FROM coursedefns WHERE STRCMP(code,'%s')=0", $this->code);
} else {
if ($this->id) {
$res = db_query("SELECT * FROM coursedefns WHERE id='%d'", $this->id);
} else {
if ($this->title) {
$res = db_query("SELECT * FROM coursedefns WHERE STRCMP(title,'%s')=0", $this->title);
} else {
Error::generate('debug', 'Not enough information to find course in CourseDefn::load().');
return false;
}
}
}
if (!$res) {
Error::generate('debug', 'CourseDefn->load: $res is null');
return false;
}
$ret = db_get_assoc($res);
if (!$ret) {
Error::generate('debug', 'CourseDefn->load: $ret is null');
return false;
}
$this->title = $ret['title'];
$this->code = $ret['code'];
$this->id = $ret['id'];
$this->descr = $ret['descr'];
$this->cid = $ret['cid'];
$this->university = $ret['university'];
return $this;
}
示例2: wikipedia_search
function wikipedia_search($procd_descr)
{
profiling_start('wikipedia_search');
$TERMS = wikipedia_process_term($procd_descr);
$url = wikipedia_url($TERMS);
$data = cached_file_get_contents($url);
Error::setPrepend($data);
Error::generate('debug', 'WIKIPEDIA');
eval('$arr = ' . $data . ';');
foreach ($arr['query']['pages'] as $k => $v) {
$title = urlencode($v['title']);
$url = urlencode($v['fullurl']);
// https://dgl.cx/2008/10/wikipedia-summary-dns
if ($k == -1) {
// not found
return array();
}
break;
}
// this is probably a topic from a random unintended field like "frequency analysis (cryptoanalysis)"
if (strlen($title) < strlen($TERMS) - 5 || strlen($title) > strlen($TERMS) + 5 || strrchr($title, '%28')) {
return array();
}
$store = array('title' => urldecode(str_replace('+', ' ', $title)), 'link' => urldecode($url), 'source' => 'wikipedia');
profiling_end('wikipedia_search');
return array($store);
}
示例3: Create
public static function Create($userCfg, $uploadPath)
{
global $ROOT;
$owner = $userCfg['owner'] or $owner = 0;
$context = $userCfg['context'] or $context = 1;
$id = static::eav_create($userCfg['name'], $owner, $context);
if ($id < 1) {
// pretty sure this shouldn't happen with current schema
Error::generate('notice', 'Filename already taken.', Error::$FLAGS['override']);
return false;
}
// Copy the file from the uploadPath to the given userCfg['path']
if (!isset($userCfg['path']) || !move_uploaded_file($uploadPath, "{$ROOT}/" . $userCfg['path'])) {
Error::generate('debug', 'Could not move file');
return false;
}
foreach ($userCfg as $attrib => $val) {
switch (strtoupper($attrib)) {
default:
$storeval = $val;
}
static::store_attrib($id, $attrib, $storeval);
}
return $id;
}
示例4: ListAll
public static function ListAll($id = 1, $type = 1)
{
Error::generate('debug', "Comment::ListAll({$id}, {$type})");
$ret = static::eav_list($id, $type, 'ORDER BY node.creation_timestamp');
if (!$ret) {
$ret = array();
}
return array_reverse($ret, true);
}
示例5: ListAllMatching
public static function ListAllMatching($val)
{
$ret = db_query("SELECT country.id, country.name\n\t\t\t\t\tFROM\t\tcountries\t\tAS country\n\t\t\t\t\tWHERE\t\tcountry.name REGEXP '.*%s.*'\n\t\t\t\t\tORDER BY\tcountry.name", $val);
if (!$ret) {
Error::generate('debug', 'Could not query db in Country::ListAll');
return array();
}
$ret = db_get_list_assoc($ret);
return $ret;
}
示例6: __construct
function __construct($url, $method, $params, $perms = 'any')
{
$method = strtolower($method);
if (!in_array($method, $this->ACCEPTED_METHODS)) {
Error::generate('fatal', 'Invalid HTTP method.');
return;
}
$this->url = $url;
$this->method = $method;
$this->params = $params;
$this->perms = $perms;
}
示例7: sigint_handler
function sigint_handler()
{
global $sock, $argv, $fp, $mch;
curl_multi_close($mch);
fclose($fp);
socket_close($sock);
unlink("/private/tmp/classmate{$argv['1']}");
db_close();
Error::showSeparator();
Error::setBgColour('#B66');
Error::generate('debug', "Finished running classmated {$argv['1']} normally");
Error::setBgColour('#555');
Error::showSeparator();
}
示例8: perform_search
function perform_search($service, $descr, $tags, $crs)
{
Error::generate('debug', "perform_search({$service},{$descr},{$tags},crs)");
switch (strtolower($service)) {
case 'youtube':
return youtube_search($descr, $tags, $crs);
case 'google':
return google_search($descr);
case 'itunesu':
return itunesu_search($descr);
case 'wikipedia':
return wikipedia_search($descr);
case 'khanacad':
return khanacad_search($descr);
}
}
示例9: ListAllMatching
public static function ListAllMatching($country_id = false, $val)
{
if ($country_id) {
$country = mysql_real_escape_string($country);
$country_constraint = "AND country.id = '{$country_id}'";
} else {
$country_constraint = '';
}
$ret = db_query("SELECT area.id, area.name, country_name\n\t\t\t\t\tFROM\t\tareas\t\t\tAS area,\n\t\t\t\t\t\t\t\tcountries\t\tAS country\n\t\t\t\t\tWHERE\t\tarea.name REGEXP '.*%s.*'\n\t\t\t\t\t\tAND\t\tarea.country = country.id\n\t\t\t\t\t\t\t\t{$country_constraint}\n\t\t\t\t\tORDER BY\tarea.name", $val);
if (!$ret) {
Error::generate('debug', 'Could not query db in Area::ListAll');
return array();
}
$ret = db_get_list_assoc($ret);
return $ret;
}
示例10: eav_list
protected static function eav_list($id, $type = 1, $orderby = 0)
{
if ($orderby === 0) {
$orderby = "ORDER BY node.creation_timestamp DESC";
}
if (!$id || $id == 0) {
Error::generate('debug', 'id is 0');
return array();
}
$ret = db_query('
SELECT node.*
FROM %ss AS node,
%ss AS parent
WHERE node.parent = parent.id
AND parent.id = \'%d\'
AND node.type = \'%d\'
%s
', static::subGetClass(), static::subGetClass(), $id, $type, $orderby);
if (!$ret) {
Error::generate('debug', 'Could not query db in hierarchical eav list');
return array();
}
//$ret = db_get_list_result($ret);
$ret = db_get_list_assoc($ret);
return $ret;
}
示例11: redirect
$args['list'] = Comment::ListAll();
redirect('comment', 'list');
}
}
} else {
if ($action == 'list') {
$args['list'] = Comment::ListAll();
include 'views/list.view.php';
} else {
if ($action == 'show') {
$args['info'] = array(array('id', $params['id']), array('subject', Comment::GetSubject($params['id'])), array('created on', Comment::GetTimestamp($params['id'])), array('body', Comment::GetAttrib($params['id'], 'body')));
include 'views/show.view.php';
} else {
if (isset($_GET['action']) && $_GET['action'] != "") {
// Action with no params
$action = $_GET['action'];
switch ($action) {
case 'create':
include 'views/create.view.php';
break;
default:
Error::generate('suspicious', "Invalid action {$action} in /file/");
redirect();
}
} else {
include 'views/index.view.php';
}
}
}
}
db_close();
示例12: get_id
protected static function get_id($name)
{
$res = db_query("SELECT id FROM %ss WHERE name='%s'", static::subGetClass(), $name);
if (!$res || !($ret = db_get_result($res))) {
Error::generate('debug', 'Could not query database in get_id');
return false;
} else {
return intval($ret);
}
}
示例13: db_connect
<?php
@(include "{$ROOT}/includes/tags.inc");
@(include "dataacquisition/google.util.php");
@(include "dataacquisition/youtube.util.php");
@(include "dataacquisition/itunesu.util.php");
@(include "dataacquisition/khanacad.util.php");
@(include "{$ROOT}/includes/subjects.inc");
@(include "{$ROOT}/includes/universities.inc");
@(include "{$ROOT}/includes/geography.inc");
db_connect();
Error::showSeparator();
Error::generate('debug', 'Starting preload process');
Error::showSeparator();
foreach (CourseDefn::ListAll() as $crs) {
Error::showSeparator();
Error::generate('debug', 'Preloading ' . $crs->university . ': ' . $crs->code);
// TODO: preload
Error::showSeparator();
}
Error::showSeparator();
Error::generate('debug', 'Ending preload process');
Error::showSeparator();
示例14: array
}
?>
<div id="sidebar_course_recommendations">People who viewed this course also viewed:</div>
<div id="sidebar_recommendation_tagcloud_hidden" class="hidden">
<?php
$ctr = 0;
Error::setPrepend($other_views);
Error::generate('debug', 'Recommendation array');
$reduced_recs = array();
$i = 0;
foreach ($other_views as $k => $v) {
$reduced_recs[$i++] = $v;
}
$n_rrecs = $i;
Error::setPrepend($reduced_recs);
Error::generate('debug', 'Reduced Recommendation array');
$topn = 10;
// limit to $topn top results
foreach ($other_views as $k => $v) {
if (++$ctr == $topn) {
break;
}
// limit to $topn top results
$id = intval($k);
$subj = ucfirst(Comment::GetSubject($id));
$crs = new CourseDefn($subj);
$success = $crs->load();
$hrefid = $crs->id;
// cloudinizr javascript is in template_end
for ($i = 0; $i < $v / $reduced_recs[min(10, $n_rrecs - 1)]; $i++) {
echo strtoupper("{$subj} ");
示例15: eav_list
protected static function eav_list($id)
{
$ret = db_query('
SELECT node.id, node.subject, node.creation_timestamp
FROM comments AS node,
comments AS parent
WHERE node.lft BETWEEN parent.lft+1 AND parent.rgt-1
AND parent.id = \'%d\'
ORDER BY node.lft
', $id);
if (!$ret) {
Error::generate('debug', 'Could not query db in hierarchical eav list');
return array();
}
$ret = db_get_list_result($ret);
return $ret;
}