本文整理汇总了PHP中w2p_Database_Query::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Database_Query::clear方法的具体用法?PHP w2p_Database_Query::clear怎么用?PHP w2p_Database_Query::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Database_Query
的用法示例。
在下文中一共展示了w2p_Database_Query::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
public function remove()
{
$q = new w2p_Database_Query();
$q->dropTable('resources');
$q->exec();
$q->clear();
$q->dropTable('resource_tasks');
$q->exec();
$q->clear();
$q->dropTable('resource_types');
$q->exec();
return null;
}
示例2: store
public function store($object_id)
{
global $db;
$object_id = (int) $object_id;
if ($object_id) {
$this->value_intvalue = (int) $this->value_intvalue;
$ins_charvalue = $this->value_charvalue == null ? '' : stripslashes($this->value_charvalue);
$q = new w2p_Database_Query();
$q->addTable('custom_fields_values');
if ($this->value_id) {
$q->addUpdate('value_charvalue', $ins_charvalue);
$q->addUpdate('value_intvalue', $this->value_intvalue);
$q->addWhere('value_id = ' . $this->value_id);
} else {
$q->addInsert('value_module', '');
$q->addInsert('value_field_id', $this->field_id);
$q->addInsert('value_object_id', $object_id);
$q->addInsert('value_charvalue', $ins_charvalue);
$q->addInsert('value_intvalue', $this->value_intvalue);
}
$rs = $q->exec();
$q->clear();
if (!$rs) {
return $db->ErrorMsg() . ' | SQL: ';
}
} else {
return 'Error: Cannot store field (' . $this->field_name . '), associated id not supplied.';
}
}
示例3: bind
public function bind($hash)
{
if (!is_array($hash)) {
return get_class($this) . "::bind failed";
} else {
$q = new w2p_Database_Query();
$q->bindHashToObject($hash, $this);
$q->clear();
return null;
}
}
示例4: authenticate
public function authenticate($username, $password)
{
global $db, $AppUI;
$this->username = $username;
$q = new w2p_Database_Query();
$q->addTable('users');
$q->addQuery('user_id, user_password');
$q->addWhere('user_username = \'' . $username . '\'');
if (!($rs = $q->exec())) {
$q->clear();
return false;
}
if (!($row = $q->fetchRow())) {
$q->clear();
return false;
}
$this->user_id = $row['user_id'];
$q->clear();
if (MD5($password) == $row['user_password']) {
return true;
}
return false;
}
示例5: load
public function load()
{
global $db;
$q = new w2p_Database_Query();
$q->addTable('custom_fields_lists');
$q->addWhere('field_id = ' . $this->field_id);
$q->addOrder('list_value');
if (!($rs = $q->exec())) {
$q->clear();
return $db->ErrorMsg();
}
while ($opt_row = $q->fetchRow()) {
$this->options[$opt_row['list_option_id']] = $opt_row['list_value'];
}
}
示例6: canDelete
public function canDelete($msg, $oid = 0, $joins = null)
{
$msg = array();
$q = new w2p_Database_Query();
$q->addTable('file_folders');
$q->addQuery('COUNT(DISTINCT file_folder_id) AS num_of_subfolders');
$q->addWhere('file_folder_parent=' . $oid);
$res1 = $q->loadResult();
if ($res1) {
$msg[] = "Can't delete folder, it has subfolders.";
//') . ': ' . implode(', ', $msg);
}
$q->clear();
$q = new w2p_Database_Query();
$q->addTable('files');
$q->addQuery('COUNT(DISTINCT file_id) AS num_of_files');
$q->addWhere('file_folder=' . $oid);
$res2 = $q->loadResult();
if ($res2) {
$msg[] = "Can't delete folder, it has files within it.";
//') . ': ' . implode(', ', $msg);
}
return $msg;
}
示例7:
$q->addQuery('usernames.user_username, usernames.user_id');
$q->addQuery('assignees.user_username as assignee_username');
$q->addQuery('count(distinct assignees.user_id) as assignee_count');
$q->addQuery('co.contact_first_name, co.contact_last_name');
$q->addQuery('CONCAT(co.contact_first_name,\' \', co.contact_last_name) AS owner');
$q->addQuery('task_milestone');
$q->addQuery('count(distinct f.file_task) as file_count');
$q->addQuery('tlog.task_log_problem');
$q->addQuery('task_access');
//subquery the parent state
$sq = new w2p_Database_Query();
$sq->addTable('tasks', 'stasks');
$sq->addQuery('COUNT(stasks.task_id)');
$sq->addWhere('stasks.task_id <> tasks.task_id AND stasks.task_parent = tasks.task_id');
$subquery = $sq->prepare();
$sq->clear();
$q->addQuery('(' . $subquery . ') AS task_nr_of_children');
$q->addTable('tasks');
$mods = $AppUI->getActiveModules();
if (!empty($mods['history']) && canView('history')) {
$q->addQuery('MAX(history_date) as last_update');
$q->leftJoin('history', 'h', 'history_item = tasks.task_id AND history_table=\'tasks\'');
}
$q->addJoin('projects', 'p', 'p.project_id = task_project', 'inner');
$q->leftJoin('users', 'usernames', 'task_owner = usernames.user_id');
$q->leftJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
$q->leftJoin('users', 'assignees', 'assignees.user_id = ut.user_id');
$q->leftJoin('contacts', 'co', 'co.contact_id = usernames.user_contact');
$q->leftJoin('task_log', 'tlog', 'tlog.task_log_task = tasks.task_id AND tlog.task_log_problem > 0');
$q->leftJoin('files', 'f', 'tasks.task_id = f.file_task');
$q->leftJoin('project_departments', 'project_departments', 'p.project_id = project_departments.project_id OR project_departments.project_id IS NULL');
示例8: indexStrings
public function indexStrings()
{
global $w2Pconfig;
$nwords_indexed = 0;
/* Workaround for indexing large files:
** Based on the value defined in config data,
** files with file_size greater than specified limit
** are not indexed for searching.
** Negative value :<=> no filesize limit
*/
$index_max_file_size = w2PgetConfig('index_max_file_size', 0);
if ($this->file_size > 0 && ($index_max_file_size < 0 || (int) $this->file_size <= $index_max_file_size * 1024)) {
// get the parser application
$parser = $w2Pconfig['parser_' . $this->file_type];
if (!$parser) {
$parser = $w2Pconfig['parser_default'];
}
if (!$parser) {
return false;
}
// buffer the file
$this->_filepath = W2P_BASE_DIR . '/files/' . $this->file_project . '/' . $this->file_real_filename;
if (file_exists($this->_filepath)) {
$fp = fopen($this->_filepath, 'rb');
$x = fread($fp, $this->file_size);
fclose($fp);
// parse it
$parser = $parser . ' ' . $this->_filepath;
$pos = strpos($parser, '/pdf');
/*
* TODO: I *really* hate using error surpression here and I would
* normally just detect if safe_mode is on and if it was, skip
* this call. Unfortunately, safe_mode has been deprecated in
* 5.3 and will be removed in 5.4
*/
if (false !== $pos) {
$x = @shell_exec(`{$parser} -`);
} else {
$x = @shell_exec(`{$parser}`);
}
// if nothing, return
if (strlen($x) < 1) {
return 0;
}
// remove punctuation and parse the strings
$x = str_replace(array('.', ',', '!', '@', '(', ')'), ' ', $x);
$warr = explode(' ', $x);
$wordarr = array();
$nwords = count($warr);
for ($x = 0; $x < $nwords; $x++) {
$newword = $warr[$x];
if (!preg_match('[!"#$%&\'()*+,\\-./:;<=>?@[\\\\]^_`{|}~]', $newword) && mb_strlen(mb_trim($newword)) > 2 && !preg_match('[0-9]', $newword)) {
$wordarr[$newword] = $x;
}
}
// filter out common strings
$ignore = w2PgetSysVal('FileIndexIgnoreWords');
$ignore = str_replace(' ,', ',', $ignore);
$ignore = str_replace(', ', ',', $ignore);
$ignore = explode(',', $ignore);
foreach ($ignore as $w) {
unset($wordarr[$w]);
}
$nwords_indexed = count($wordarr);
// insert the strings into the table
while (list($key, $val) = each($wordarr)) {
$q = new w2p_Database_Query();
$q->addTable('files_index');
$q->addReplace('file_id', $this->file_id);
$q->addReplace('word', $key);
$q->addReplace('word_placement', $val);
$q->exec();
$q->clear();
}
} else {
//TODO: if the file doesn't exist.. should we delete the db record?
}
}
$q = new w2p_Database_Query();
$q->addTable('files');
$q->addUpdate('file_indexed', 1);
$q->addWhere('file_id = ' . $this->file_id);
$q->exec();
return $nwords_indexed;
}
示例9: showcompany
function showcompany($company, $restricted = false)
{
global $AppUI, $allpdfdata, $log_start_date, $log_end_date, $log_all;
$q = new w2p_Database_Query();
$q->addTable('projects');
$q->addQuery('project_id, project_name');
$q->addWhere('project_company = ' . (int) $company);
$projects = $q->loadHashList();
$q->clear();
$q->addTable('companies');
$q->addQuery('company_name');
$q->addWhere('company_id = ' . (int) $company);
$company_name = $q->loadResult();
$q->clear();
$table = '<h2>Company: ' . $company_name . '</h2>
<table cellspacing="1" cellpadding="4" border="0" class="tbl">';
$project_row = '
<tr>
<th>' . $AppUI->_('Project') . '</th>';
$pdfth[] = $AppUI->_('Project');
$project_row .= '<th>' . $AppUI->_('Total') . '</th></tr>';
$pdfth[] = $AppUI->_('Total');
$pdfdata[] = $pdfth;
$hours = 0.0;
$table .= $project_row;
foreach ($projects as $project => $name) {
$pdfproject = array();
$pdfproject[] = $name;
$project_hours = 0;
$project_row = '<tr><td>' . $name . '</td>';
$q->addTable('projects');
$q->addTable('tasks');
$q->addTable('task_log');
$q->addQuery('task_log_costcode, SUM(task_log_hours) as hours');
$q->addWhere('project_id = ' . (int) $project);
$q->addWhere('project_active = 1');
if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
$q->addWhere('project_status <> ' . (int) $template_status);
}
if ($log_start_date != 0 && !$log_all) {
$q->addWhere('task_log_date >=' . $log_start_date);
}
if ($log_end_date != 0 && !$log_all) {
$q->addWhere('task_log_date <=' . $log_end_date);
}
if ($restricted) {
$q->addWhere('task_log_creator = ' . (int) $AppUI->user_id);
}
$q->addWhere('project_id = task_project');
$q->addWhere('task_id = task_log_task');
$q->addGroup('project_id');
$task_logs = $q->loadHashList();
$q->clear();
foreach ($task_logs as $task_log) {
$project_hours += $task_log;
}
$project_row .= '<td style="text-align:right;">' . sprintf('%.2f', round($project_hours, 2)) . '</td></tr>';
$pdfproject[] = round($project_hours, 2);
$hours += $project_hours;
if ($project_hours > 0) {
$table .= $project_row;
$pdfdata[] = $pdfproject;
}
}
if ($hours > 0) {
$pdfdata[] = array($AppUI->_('Total'), round($hours, 2));
$allpdfdata[$company_name] = $pdfdata;
echo $table;
echo '<tr><td>' . $AppUI->_('Total') . '</td><td style="text-align:right;">' . sprintf('%.2f', round($hours, 2)) . '</td></tr></table>';
}
return $hours;
}
示例10: hook_cron
public function hook_cron()
{
if (w2PgetConfig('system_update_check', true)) {
$lastCheck = w2PgetConfig('system_update_last_check', '');
$nowDate = new DateTime("now");
if ('' == $lastCheck) {
$checkForUpdates = true;
} else {
$systemDate = new DateTime($lastCheck);
$difference = 0;
//$nowDate->diff($systemDate)->format('%d');
$checkForUpdates = $difference >= 7 ? true : false;
}
if ($checkForUpdates) {
$AppUI = new w2p_Core_CAppUI();
$configList = array();
$moduleList = $AppUI->getLoadableModuleList();
foreach ($moduleList as $module) {
$configList[$module['mod_directory']] = $module['mod_version'];
}
$configList['w2p_ver'] = $AppUI->getVersion();
$configList['php_ver'] = PHP_VERSION;
$configList['database'] = $this->_w2Pconfig['dbtype'];
$configList['server'] = $_SERVER['SERVER_SOFTWARE'];
$configList['connector'] = php_sapi_name();
$configList['database_ver'] = mysql_get_client_info();
$libraries = array('tidy', 'json', 'libxml', 'mysql');
foreach ($libraries as $library) {
$configList[$library . '_extver'] = phpversion($library);
}
if (function_exists('gd_info')) {
$lib_version = gd_info();
$configList['gd_extver'] = $lib_version['GD Version'];
}
if (function_exists('curl_version')) {
$lib_version = curl_version();
$configList['curl_extver'] = $lib_version['version'];
}
$request = new w2p_Utilities_HTTPRequest('http://stats.web2project.net');
$request->addParameters($configList);
$result = $request->processRequest();
$data = json_decode($result);
$q = new w2p_Database_Query();
$q->addTable('config');
if ('' == w2PgetConfig('available_version', '')) {
$q->addInsert('config_name', 'available_version');
$q->addInsert('config_value', $data->w2p_ver);
$q->addInsert('config_group', 'admin_system');
$q->addInsert('config_type', 'text');
} else {
$q->addUpdate('config_value', $data->w2p_ver);
$q->addWhere("config_name = 'available_version'");
}
$q->exec();
$q->clear();
$q->addTable('config');
$q->addUpdate('config_value', date('Y-m-d H:i:s'));
$q->addWhere("config_name = 'system_update_last_check'");
$q->exec();
}
}
}
示例11: setContactMethods
public function setContactMethods(array $methods)
{
$q = new w2p_Database_Query();
$q->setDelete('contacts_methods');
$q->addWhere('contact_id=' . (int) $this->contact_id);
$q->exec();
$q->clear();
if (!empty($methods)) {
$q = new w2p_Database_Query();
$q->addTable('contacts_methods');
$q->addInsert('contact_id', (int) $this->contact_id);
foreach ($methods as $name => $value) {
if (!empty($value)) {
$q->addInsert('method_name', $name);
$q->addInsert('method_value', $value);
$q->exec();
}
}
$q->clear();
}
}
示例12: delete
public function delete()
{
$q = new w2p_Database_Query();
$q->setDelete('user_preferences');
$q->addWhere('pref_user = ' . (int) $this->pref_user);
$q->addWhere('pref_name = \'' . $this->pref_name . '\'');
if (!$q->exec()) {
$q->clear();
return db_error();
} else {
$q->clear();
return null;
}
}
示例13: createsqluser
public function createsqluser($username, $password, $email, $first, $last)
{
global $db, $AppUI;
$c = new CContact();
$c->contact_first_name = $first;
$c->contact_last_name = $last;
$c->contact_order_by = $first . ' ' . $last;
$c->contact_email = $email;
$c->store();
$q = new w2p_Database_Query();
$q->addTable('users');
$q->addInsert('user_username', $username);
$q->addInsert('user_password', $password);
$q->addInsert('user_type', '1');
$q->addInsert('user_contact', $c->contact_id);
if (!$q->exec()) {
die($AppUI->_('Failed to create user credentials'));
}
$user_id = $db->Insert_ID();
$this->user_id = $user_id;
$q->clear();
$acl =& $AppUI->acl();
$acl->insertUserRole($acl->get_group_id('anon'), $this->user_id);
}
示例14: __extract_from_role_perms
/**
* @param $module
* @param $mod_data
*
* @return Value
*/
function __extract_from_role_perms($module, $mod_data)
{
$q = new w2p_Database_Query();
$q->addTable($module['permissions_item_table']);
$q->addQuery($module['permissions_item_label']);
$q->addWhere($module['permissions_item_field'] . '=' . $mod_data['name']);
$data = $q->loadResult();
$q->clear();
return $data;
}
示例15: storeTokenTask
/**
*
* @param w2p_Core_CAppUI $AppUI
* @param CProject $project_id
*
* The point of this function is to create/update a task to represent a
* subproject.
*
*/
public static function storeTokenTask(w2p_Core_CAppUI $AppUI, $project_id)
{
$subProject = new CProject();
//TODO: We need to convert this from static to use ->overrideDatabase() for testing.
$subProject->load($project_id);
if ($subProject->project_parent > 0 && $subProject->project_id != $subProject->project_parent) {
$q = new w2p_Database_Query();
$q->addTable('tasks');
$q->addQuery('MIN(task_start_date) AS min_task_start_date');
$q->addQuery('MAX(task_end_date) AS max_task_end_date');
$q->addWhere('task_project = ' . $subProject->project_id);
$q->addWhere('task_status <> -1');
$projectDates = $q->loadList();
$q->clear();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_represents_project = ' . $subProject->project_id);
$task_id = (int) $q->loadResult();
$task = new CTask();
//TODO: We need to convert this from static to use ->overrideDatabase() for testing.
if ($task_id) {
$task->load($task_id);
} else {
$task->task_description = $task->task_name;
$task->task_priority = $subProject->project_priority;
$task->task_project = $subProject->project_parent;
$task->task_represents_project = $subProject->project_id;
$task->task_owner = $AppUI->user_id;
}
$task->task_name = $AppUI->_('Subproject') . ': ' . $subProject->project_name;
$task->task_duration_type = 1;
$task->task_duration = $subProject->project_scheduled_hours;
$task->task_start_date = $projectDates[0]['min_task_start_date'];
$task->task_end_date = $projectDates[0]['max_task_end_date'];
$task->task_percent_complete = $subProject->project_percent_complete;
$task->store();
//TODO: we should do something with this store result?
}
}