本文整理汇总了PHP中db_convert函数的典型用法代码示例。如果您正苦于以下问题:PHP db_convert函数的具体用法?PHP db_convert怎么用?PHP db_convert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_convert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flush
public function flush($monitor)
{
$metrics = $monitor->getMetrics();
$columns = array();
$values = array();
foreach ($metrics as $name => $metric) {
if (!empty($monitor->{$name})) {
$columns[] = $name;
if ($metrics[$name]->_type == 'int' || $metrics[$name]->_type == 'double') {
$values[] = $GLOBALS['db']->quote($monitor->{$name});
} else {
if ($metrics[$name]->_type == 'datetime') {
$values[] = $GLOBALS['db']->dbType == 'oci8' ? db_convert("'" . $monitor->{$name} . "'", 'datetime') : "'" . $monitor->{$name} . "'";
} else {
$values[] = "'" . $GLOBALS['db']->quote($monitor->{$name}) . "'";
}
}
}
}
//foreach
if (empty($values)) {
return;
}
if ($monitor->run_count == 1) {
if ($GLOBALS['db']->dbType == 'oci8') {
} else {
$query = "INSERT INTO {$monitor->table_name} (" . implode(",", $columns) . " ) VALUES ( " . implode(",", $values) . ')';
$GLOBALS['db']->query($query);
}
} else {
$query = "UPDATE {$monitor->table_name} set run_count={$monitor->run_count}, sec_avg={$monitor->sec_avg}, sec_total={$monitor->sec_total}, date_modified='{$monitor->date_modified}' where query_hash = '{$monitor->query_hash}'";
$GLOBALS['db']->query($query);
}
}
示例2: flush
public function flush($monitor)
{
$metrics = $monitor->getMetrics();
$columns = array();
$values = array();
foreach ($metrics as $name => $metric) {
if (!empty($monitor->{$name})) {
$columns[] = $name;
if ($metrics[$name]->_type == 'int' || $metrics[$name]->_type == 'double') {
$values[] = $GLOBALS['db']->quote($monitor->{$name});
} else {
if ($metrics[$name]->_type == 'datetime') {
$values[] = $GLOBALS['db']->dbType == 'oci8' ? db_convert("'" . $monitor->{$name} . "'", 'datetime') : "'" . $monitor->{$name} . "'";
} else {
$values[] = "'" . $GLOBALS['db']->quote($monitor->{$name}) . "'";
}
}
}
}
//foreach
if (empty($values)) {
return;
}
if ($monitor->round_trips == 1) {
$GLOBALS['db']->query("UPDATE {$monitor->table_name} SET active = 0 WHERE user_id = '{$monitor->user_id}' AND active = '1' AND session_id != '{$monitor->session_id}'");
$query = "INSERT INTO {$monitor->table_name} (" . implode(",", $columns) . " ) VALUES ( " . implode(",", $values) . ')';
$GLOBALS['db']->query($query);
} else {
$query = "UPDATE {$monitor->table_name} SET date_end = '{$monitor->date_end}' , seconds = {$monitor->seconds}, active = '{$monitor->active}', round_trips = {$monitor->round_trips} WHERE session_id = '{$monitor->session_id}'";
$GLOBALS['db']->query($query);
}
}
示例3: flush
public function flush($monitor)
{
$metrics = $monitor->getMetrics();
$columns = array();
$values = array();
foreach ($metrics as $name => $metric) {
if (!empty($monitor->{$name})) {
$columns[] = $name;
if ($metrics[$name]->_type == 'int' || $metrics[$name]->_type == 'double') {
$values[] = $GLOBALS['db']->quote($monitor->{$name});
} else {
if ($metrics[$name]->_type == 'datetime') {
$values[] = $GLOBALS['db']->dbType == 'oci8' ? db_convert("'" . $monitor->{$name} . "'", 'datetime') : "'" . $monitor->{$name} . "'";
} else {
$values[] = "'" . $GLOBALS['db']->quote($monitor->{$name}) . "'";
}
}
}
}
//foreach
if (empty($values)) {
return;
}
$query = "INSERT INTO {$monitor->table_name} (" . implode(",", $columns) . " ) VALUES ( " . implode(",", $values) . ')';
$GLOBALS['db']->query($query);
}
示例4: getDataset
protected function getDataset()
{
global $db;
$query = "Select count(id) FROM calls " . " WHERE DATE_FORMAT(calls.date_start, '%Y-%m-%d') >= " . db_convert("'" . $this->v_date_start . "'", 'date') . " AND DATE_FORMAT(calls.date_end, '%Y-%m-%d') <= " . db_convert("'" . $this->v_date_end . "'", 'date') . " AND calls.deleted=0";
if (count($this->v_ids) > 0) {
$query .= " AND calls.assigned_user_id IN ('" . implode("','", $this->v_ids) . "') ";
}
$result = $db->query($query);
$row = $db->fetchByAssoc($result);
$query2 = "Select count(id) FROM meetings " . " WHERE DATE_FORMAT(meetings.date_start, '%Y-%m-%d') >= " . db_convert("'" . $this->v_date_start . "'", 'date') . " AND DATE_FORMAT(meetings.date_end, '%Y-%m-%d') <= " . db_convert("'" . $this->v_date_end . "'", 'date') . " AND meetings.deleted=0";
if (count($this->v_ids) > 0) {
$query2 .= " AND meetings.assigned_user_id IN ('" . implode("','", $this->v_ids) . "') ";
}
$result2 = $db->query($query2);
$row2 = $db->fetchByAssoc($result2);
$query3 = "Select count(id) FROM opportunities";
$query3 .= " WHERE DATE_FORMAT(opportunities.date_closed, '%Y-%m-%d') >= " . db_convert("'" . $this->v_date_start . "'", 'date') . " AND DATE_FORMAT(opportunities.date_closed, '%Y-%m-%d') <= " . db_convert("'" . $this->v_date_end . "'", 'date') . " AND opportunities.deleted=0";
if (count($this->v_ids) > 0) {
$query3 .= " AND opportunities.assigned_user_id IN ('" . implode("','", $this->v_ids) . "') ";
}
$result3 = $db->query($query3);
$row3 = $db->fetchByAssoc($result3);
$query4 = "Select count(id) FROM opportunities WHERE opportunities.sales_stage = 'completed'";
$query4 .= " AND DATE_FORMAT(opportunities.date_closed, '%Y-%m-%d') >= " . db_convert("'" . $this->v_date_start . "'", 'date') . " AND DATE_FORMAT(opportunities.date_closed, '%Y-%m-%d') <= " . db_convert("'" . $this->v_date_end . "'", 'date') . " AND opportunities.deleted=0";
if (count($this->v_ids) > 0) {
$query4 .= " AND opportunities.assigned_user_id IN ('" . implode("','", $this->v_ids) . "') ";
}
$result4 = $db->query($query4);
$row4 = $db->fetchByAssoc($result4);
$returnArray = array(array('a' => 'Звонки', 'total' => $row['count(id)']), array('a' => 'Встречи', 'total' => $row2['count(id)']), array('a' => 'Сделки', 'total' => $row3['count(id)']), array('a' => 'Успешные сделки', 'total' => $row4['count(id)']));
return $returnArray;
}
示例5: constructQuery
/**
* @see DashletGenericChart::constructQuery()
*/
protected function constructQuery()
{
$query = "SELECT sales_stage," . db_convert('opportunities.date_closed', 'date_format', array("'%Y-%m'"), array("'YYYY-MM'")) . " as m, " . "sum(amount_usdollar/1000) as total, count(*) as opp_count FROM opportunities ";
$this->getSeedBean()->add_team_security_where_clause($query);
$query .= " WHERE opportunities.date_closed >= " . db_convert("'" . $this->obm_date_start . "'", 'date') . " AND opportunities.date_closed <= " . db_convert("'" . $this->obm_date_end . "'", 'date') . " AND opportunities.deleted=0";
if (count($this->obm_ids) > 0) {
$query .= " AND opportunities.assigned_user_id IN ('" . implode("','", $this->obm_ids) . "')";
}
$query .= " GROUP BY sales_stage," . db_convert('opportunities.date_closed', 'date_format', array("'%Y-%m'"), array("'YYYY-MM'")) . " ORDER BY m";
return $query;
}
示例6: display
public function display()
{
$data = array();
$ss = new Sugar_Smarty();
$focus = BeanFactory::getBean('TeamNotices');
$today = db_convert("'" . TimeDate::getInstance()->nowDbDate() . "'", 'date');
$query = $focus->create_new_list_query("date_start", $focus->table_name . ".date_start <= {$today} and " . $focus->table_name . ".date_end >= {$today} and " . $focus->table_name . '.status=\'Visible\'');
if ($result = $focus->db->query($query)) {
while ($row = $focus->db->fetchByAssoc($result)) {
$data[] = $row;
}
}
$ss->assign("data", $data);
return parent::display() . $ss->fetch('modules/TeamNotices/Dashlets/TeamNoticesDashlet/TeamNoticesDashlet.tpl');
}
示例7: UWrebuild
function UWrebuild()
{
global $db;
Log::info('Deleting Relationship Cache. Relationships will automatically refresh.');
echo "\n\t<div id='rrresult'></div>\n\t<script>\n\t\tvar xmlhttp=false;\n\t\t/*@cc_on @*/\n\t\t/*@if (@_jscript_version >= 5)\n\t\t// JScript gives us Conditional compilation, we can cope with old IE versions.\n\t\t// and security blocked creation of the objects.\n\t\t try {\n\t\t xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");\n\t\t } catch (e) {\n\t\t try {\n\t\t xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");\n\t\t } catch (E) {\n\t\t xmlhttp = false;\n\t\t }\n\t\t }\n\t\t@end @*/\n\t\tif (!xmlhttp && typeof XMLHttpRequest!='undefined') {\n\t\t\ttry {\n\t\t\t\txmlhttp = new XMLHttpRequest();\n\t\t\t} catch (e) {\n\t\t\t\txmlhttp = false;\n\t\t\t}\n\t\t}\n\t\tif (!xmlhttp && window.createRequest) {\n\t\t\ttry {\n\t\t\t\txmlhttp = window.createRequest();\n\t\t\t} catch (e) {\n\t\t\t\txmlhttp = false;\n\t\t\t}\n\t\t}\n\t\txmlhttp.onreadystatechange = function() {\n\t\t if(xmlhttp.readyState == 4) {\n\t\t document.getElementById('rrresult').innerHTML = xmlhttp.responseText;\n\t\t }\n\t\t }\n\t\txmlhttp.open('GET', 'index.php?module=Administration&action=RebuildRelationship&to_pdf=true', true);\n\t\txmlhttp.send(null);\n\t\t</script>";
Log::info('Rebuilding everything.');
require_once 'ModuleInstall/ModuleInstaller.php';
$mi = new ModuleInstaller();
$mi->rebuild_all();
$query = "DELETE FROM versions WHERE name='Rebuild Extensions'";
Log::info($query);
$db->query($query);
// insert a new database row to show the rebuild extensions is done
$id = create_guid();
$gmdate = TimeDate::getInstance()->nowDb();
$date_entered = db_convert("'{$gmdate}'", 'datetime');
$query = 'INSERT INTO versions (id, deleted, date_entered, date_modified, modified_user_id, created_by, name, file_version, db_version) ' . "VALUES ('{$id}', '0', {$date_entered}, {$date_entered}, '1', '1', 'Rebuild Extensions', '4.0.0', '4.0.0')";
Log::info($query);
$db->query($query);
}
示例8: ShowUsersCumulativeLoggedInTime
/**
* ShowUsersCumulativeLoggedInTime
*
* Returns a time formmated display of total time logged in for all users from
* the given date interval
*
* @param $data_selected - Optional date filter value (default is one week from today)
* @return Array - dataset
*/
public function ShowUsersCumulativeLoggedInTime($date_selected = null)
{
if (!empty($date_selected)) {
$timeSpan = db_convert("'" . $date_selected . "'", "datetime");
} else {
$firstDay = $GLOBALS['timedate']->get_first_day_of_week($GLOBALS['current_user']);
$timeSpan = db_convert("'" . $GLOBALS['timedate']->getNow()->get_day_by_index_this_week($firstDay)->asDb() . "'", "datetime");
}
$args = array($timeSpan);
$result = $this->execute($this->setup('ShowUsersCumulativeLoggedInTime', $args));
$data = array();
foreach ($result as $row) {
$data[] = array('username' => $row['user_name'], 'total_login_time' => $this->convertSecondsToTime($row['total_login_time'], true));
}
return array_values($data);
}
示例9: UWrebuild
/**
* runs rebuild scripts
*/
function UWrebuild()
{
global $db;
global $path;
/*
//CCL - Comment this block out, it is called in end.php
logThis('Rebuilding everything...', $path);
require_once('modules/Administration/QuickRepairAndRebuild.php');
$randc = new RepairAndClear();
$randc->repairAndClearAll(array('clearAll'),array(translate('LBL_ALL_MODULES')), false, false);
*/
$query = "DELETE FROM versions WHERE name='Rebuild Extensions'";
$db->query($query);
logThis('Registering rebuild record: ' . $query, $path);
logThis('Rebuild done.', $path);
// insert a new database row to show the rebuild extensions is done
$id = create_guid();
$gmdate = gmdate('Y-m-d H:i:s');
$date_entered = db_convert("'{$gmdate}'", 'datetime');
$query = 'INSERT INTO versions (id, deleted, date_entered, date_modified, modified_user_id, created_by, name, file_version, db_version) ' . "VALUES ('{$id}', '0', {$date_entered}, {$date_entered}, '1', '1', 'Rebuild Extensions', '4.0.0', '4.0.0')";
$db->query($query);
logThis('Registering rebuild record in versions table: ' . $query, $path);
}
示例10: retrieveSchedulers
/**
* This function retrieves valid jobs, parses the cron format, then returns
* an array of [JOB_ID][EXEC_TIME][JOB]
*
* @return $executeJobs multi-dimensional array
* [job_id][execute_time]
*/
function retrieveSchedulers()
{
$GLOBALS['log']->info('Gathering Schedulers');
$executeJobs = array();
$query = "SELECT id " . "FROM schedulers " . "WHERE deleted=0 " . "AND status = 'Active' " . "AND date_time_start < " . db_convert("'" . gmdate('Y-m-d H:i:s') . "'", 'datetime') . " " . "AND (date_time_end > " . db_convert("'" . gmdate('Y-m-d H:i:s') . "'", 'datetime') . " OR date_time_end IS NULL)";
$result = $this->db->query($query);
$rows = 0;
$executeTimes = array();
$executeIds = array();
$executeJobTimes = array();
while (($arr = $this->db->fetchByAssoc($result)) != null) {
$focus = new Scheduler();
$focus->retrieve($arr['id']);
$executeTimes[$rows] = $this->deriveDBDateTimes($focus);
if (count($executeTimes) > 0) {
foreach ($executeTimes as $k => $time) {
$executeIds[$rows] = $focus->id;
$executeJobTimes[$rows] = $time;
}
}
$rows++;
}
$executeJobs['ids'] = $executeIds;
$executeJobs['times'] = $executeJobTimes;
return $executeJobs;
}
示例11: constructQuery
function constructQuery()
{
global $current_user;
global $timedate;
//get the dates to display
$user_date_start = $current_user->getPreference('mypbss_date_start');
if (!empty($user_date_start) && !isset($_REQUEST['mypbss_date_start'])) {
$date_start = $user_date_start;
$GLOBALS['log']->debug("USER PREFERENCES['mypbss_date_start'] is:");
$GLOBALS['log']->debug($user_date_start);
} elseif (isset($_REQUEST['mypbss_date_start']) && $_REQUEST['mypbss_date_start'] != '') {
$date_start = $_REQUEST['mypbss_date_start'];
$current_user->setPreference('mypbss_date_start', $_REQUEST['mypbss_date_start']);
$GLOBALS['log']->debug("_REQUEST['mypbss_date_start'] is:");
$GLOBALS['log']->debug($_REQUEST['mypbss_date_start']);
$GLOBALS['log']->debug("USER PREFERENCES['mypbss_date_start'] is:");
$GLOBALS['log']->debug($current_user->getPreference('mypbss_date_start'));
} else {
$date_start = $timedate->nowDate();
}
$user_date_end = $current_user->getPreference('mypbss_date_end');
if (!empty($user_date_end) && !isset($_REQUEST['mypbss_date_end'])) {
$date_end = $user_date_end;
$GLOBALS['log']->debug("USER PREFERENCES['mypbss_date_end'] is:");
$GLOBALS['log']->debug($user_date_end);
} elseif (isset($_REQUEST['mypbss_date_end']) && $_REQUEST['mypbss_date_end'] != '') {
$date_end = $_REQUEST['mypbss_date_end'];
$current_user->setPreference('mypbss_date_end', $_REQUEST['mypbss_date_end']);
$GLOBALS['log']->debug("_REQUEST['mypbss_date_end'] is:");
$GLOBALS['log']->debug($_REQUEST['mypbss_date_end']);
$GLOBALS['log']->debug("USER PREFERENCES['mypbss_date_end'] is:");
$GLOBALS['log']->debug($current_user->getPreference('mypbss_date_end'));
} else {
$date_end = $timedate->asUserDate($timedate->fromString("2010-01-01"));
$GLOBALS['log']->debug("USER PREFERENCES['mypbss_date_end'] not found. Using: " . $date_end);
}
$user_id = array($current_user->id);
$opp = new Opportunity();
$where = "";
//build the where clause for the query that matches $user
$count = count($user_id);
$id = array();
$user_list = get_user_array(false);
foreach ($user_id as $key) {
$new_ids[$key] = $user_list[$key];
}
if ($count > 0) {
foreach ($new_ids as $the_id => $the_name) {
$id[] = "'" . $the_id . "'";
}
$ids = join(",", $id);
$where .= "opportunities.assigned_user_id IN ({$ids}) ";
}
//build the where clause for the query that matches $datax
$count = count($datax);
$dataxArr = array();
if ($count > 0) {
foreach ($datax as $key => $value) {
$dataxArr[] = "'" . $key . "'";
}
$dataxArr = join(",", $dataxArr);
$where .= "AND opportunities.sales_stage IN\t({$dataxArr}) ";
}
//build the where clause for the query that matches $date_start and $date_end
$where .= "\tAND opportunities.date_closed >= " . db_convert("'" . $date_start . "'", 'date') . "\n\t\t\t\t\tAND opportunities.date_closed <= " . db_convert("'" . $date_end . "'", 'date');
$where .= "\tAND opportunities.assigned_user_id = users.id AND opportunities.deleted=0 ";
//Now do the db queries
//query for opportunity data that matches $datax and $user
$query = "\tSELECT opportunities.sales_stage,\n\t\t\t\t\t\tusers.user_name,\n\t\t\t\t\t\topportunities.assigned_user_id,\n\t\t\t\t\t\tcount( * ) AS opp_count,\n\t\t\t\t\t\tsum(amount_usdollar/1000) AS total\n\t\t\t\t\tFROM users,opportunities ";
$query .= "WHERE " . $where;
$query .= " GROUP BY opportunities.sales_stage,users.user_name,opportunities.assigned_user_id";
return $query;
}
示例12: rebuildExtensions
public function rebuildExtensions()
{
global $mod_strings;
if ($this->show_output) {
echo $mod_strings['LBL_QR_REBUILDEXT'];
}
global $current_user;
require_once 'ModuleInstall/ModuleInstaller.php';
$mi = new ModuleInstaller();
$mi->rebuild_all(!$this->show_output);
// Remove the "Rebuild Extensions" red text message on admin logins
if ($this->show_output) {
echo $mod_strings['LBL_REBUILD_REL_UPD_WARNING'];
}
// clear the database row if it exists (just to be sure)
$query = "DELETE FROM versions WHERE name='Rebuild Extensions'";
$GLOBALS['log']->info($query);
$GLOBALS['db']->query($query);
// insert a new database row to show the rebuild extensions is done
$id = create_guid();
$gmdate = gmdate('Y-m-d H:i:s');
$date_entered = db_convert("'{$gmdate}'", 'datetime');
$query = 'INSERT INTO versions (id, deleted, date_entered, date_modified, modified_user_id, created_by, name, file_version, db_version) ' . "VALUES ('{$id}', '0', {$date_entered}, {$date_entered}, '1', '1', 'Rebuild Extensions', '4.0.0', '4.0.0')";
$GLOBALS['log']->info($query);
$GLOBALS['db']->query($query);
// unset the session variable so it is not picked up in DisplayWarnings.php
if (isset($_SESSION['rebuild_extensions'])) {
unset($_SESSION['rebuild_extensions']);
}
}
示例13: sync_get_modified_relationships
/**
* Get a list of the relationship records that have been modified within a
* specified date range. This is used to perform a sync with a mobile client.
* The results are paged.
*
* @param xsd:string $session
* @param xsd:string $module_name
* @param xsd:string $related_module
* @param xsd:string $from_date
* @param xsd:string $to_date
* @param xsd:int $offset
* @param xsd:int $max_results
* @param xsd:int $deleted
* @param xsd:int $module_id
* @param tns:select_fields $select_fields
* @param tns:select_fields $ids
* @param xsd:string $relationship_name
* @param xsd:string $deletion_date
* @param xsd:int $php_serialize
* @return
*/
function sync_get_modified_relationships($session, $module_name, $related_module, $from_date, $to_date, $offset, $max_results, $deleted, $module_id = '', $select_fields = array(), $ids = array(), $relationship_name = '', $deletion_date = '', $php_serialize = 1)
{
global $beanList, $beanFiles;
$error = new SoapError();
$output_list = array();
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
}
if (empty($beanList[$module_name]) || empty($beanList[$related_module])) {
$error->set_error('no_module');
return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
}
global $current_user;
if (!check_modules_access($current_user, $module_name, 'read') || !check_modules_access($current_user, $related_module, 'read')) {
$error->set_error('no_access');
return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
}
// Cast to integer
$deleted = (int) $deleted;
if ($max_results > 0 || $max_results == '-99') {
global $sugar_config;
$sugar_config['list_max_entries_per_page'] = $max_results;
}
$date_query = "(m1.date_modified > " . db_convert("'" . $GLOBALS['db']->quote($from_date) . "'", 'datetime') . " AND m1.date_modified <= " . db_convert("'" . $GLOBALS['db']->quote($to_date) . "'", 'datetime') . " AND {0}.deleted = {$deleted})";
if (isset($deletion_date) && !empty($deletion_date)) {
$date_query .= " OR ({0}.date_modified > " . db_convert("'" . $GLOBALS['db']->quote($deletion_date) . "'", 'datetime') . " AND {0}.date_modified <= " . db_convert("'" . $GLOBALS['db']->quote($to_date) . "'", 'datetime') . " AND {0}.deleted = 1)";
}
$in = '';
if (isset($ids) && !empty($ids)) {
foreach ($ids as $value) {
if (empty($in)) {
$in .= "('" . $GLOBALS['db']->quote($value) . "'";
} else {
$in .= ",'" . $GLOBALS['db']->quote($value) . "'";
}
}
$in .= ')';
}
$query = '';
if (isset($in) && !empty($in)) {
$query .= "( {$date_query} AND m1.id IN {$in}) OR (m1.id NOT IN {$in} AND {0}.deleted = 0)";
} else {
$query .= "( {0}.deleted = 0)";
}
if (isset($module_id) && !empty($module_id)) {
//if(isset($in) && !empty($in)){
$query .= " AND";
//}
$query .= " m2.id = '" . $GLOBALS['db']->quote($module_id) . "'";
}
if ($related_module == 'Meetings' || $related_module == 'Calls') {
$query = string_format($query, array('m1'));
}
$results = retrieve_modified_relationships($module_name, $related_module, $query, $deleted, $offset, $max_results, $select_fields, $relationship_name);
$list = $results['result'];
$xml = '<?xml version="1.0" encoding="utf-8"?><items>';
foreach ($list as $value) {
$val = array_get_return_value($value, $results['table_name']);
if ($php_serialize == 0) {
$xml .= get_name_value_xml($val, $module_name);
}
$output_list[] = $val;
}
$xml .= '</items>';
$next_offset = $offset + sizeof($output_list);
if ($php_serialize == 0) {
$myoutput = base64_encode($xml);
} else {
$myoutput = get_encoded($output_list);
}
return array('result_count' => sizeof($output_list), 'next_offset' => 0, 'total_count' => sizeof($output_list), 'field_list' => array(), 'entry_list' => $myoutput, 'error' => $error->get_soap_array());
}
示例14: _generateSearchImportWhereClause
/**
* Generate the where clause for searching imported emails.
*
*/
function _generateSearchImportWhereClause()
{
global $timedate;
//The clear button was removed so if a user removes the asisgned user name, do not process the id.
if (empty($_REQUEST['assigned_user_name']) && !empty($_REQUEST['assigned_user_id'])) {
unset($_REQUEST['assigned_user_id']);
}
$availableSearchParam = array('name' => array('table_name' => 'emails'), 'data_parent_id_search' => array('table_name' => 'emails', 'db_key' => 'parent_id', 'opp' => '='), 'assigned_user_id' => array('table_name' => 'emails', 'opp' => '='));
$additionalWhereClause = array();
foreach ($availableSearchParam as $key => $properties) {
if (!empty($_REQUEST[$key])) {
$db_key = isset($properties['db_key']) ? $properties['db_key'] : $key;
$searchValue = $_REQUEST[$key];
$opp = isset($properties['opp']) ? $properties['opp'] : 'like';
if ($opp == 'like') {
$searchValue = $searchValue . "%";
}
$additionalWhereClause[] = "{$properties['table_name']}.{$db_key} {$opp} '{$searchValue}' ";
}
}
$isDateFromSearchSet = !empty($_REQUEST['searchDateFrom']);
$isdateToSearchSet = !empty($_REQUEST['searchDateTo']);
$bothDateRangesSet = $isDateFromSearchSet & $isdateToSearchSet;
//Hanlde date from and to seperately
if ($bothDateRangesSet) {
$dbFormatDateFrom = $timedate->to_db_date($_REQUEST['searchDateFrom'], false);
$dbFormatDateFrom = db_convert("'" . $dbFormatDateFrom . "'", 'datetime');
$dbFormatDateTo = $timedate->to_db_date($_REQUEST['searchDateTo'], false);
$dbFormatDateTo = db_convert("'" . $dbFormatDateTo . "'", 'datetime');
$additionalWhereClause[] = "( emails.date_sent >= {$dbFormatDateFrom} AND\n emails.date_sent <= {$dbFormatDateTo} )";
} elseif ($isdateToSearchSet) {
$dbFormatDateTo = $timedate->to_db_date($_REQUEST['searchDateTo'], false);
$dbFormatDateTo = db_convert("'" . $dbFormatDateTo . "'", 'datetime');
$additionalWhereClause[] = "emails.date_sent <= {$dbFormatDateTo} ";
} elseif ($isDateFromSearchSet) {
$dbFormatDateFrom = $timedate->to_db_date($_REQUEST['searchDateFrom'], false);
$dbFormatDateFrom = db_convert("'" . $dbFormatDateFrom . "'", 'datetime');
$additionalWhereClause[] = "emails.date_sent >= {$dbFormatDateFrom} ";
}
$additionalWhereClause = implode(" AND ", $additionalWhereClause);
return $additionalWhereClause;
}
示例15: generateSearchWhere
//.........这里部分代码省略.........
$operator = 'db_date';
} else {
if ($GLOBALS['db']->dbType == 'mssql') {
if (preg_match('/^\\d{4}.\\d{1,2}$/', $field_value) == 0) {
$field_value = "Convert(DateTime, '" . $timedate->to_db_date($field_value, false) . "')";
}
$operator = 'db_date';
} else {
$field_value = $timedate->to_db_date($field_value, false);
$operation = '=';
}
}
}
}
if ($type == 'datetime' || $type == 'datetimecombo') {
$dates = $timedate->getDayStartEndGMT($field_value);
$field_value = $dates["start"] . "<>" . $dates["end"];
$operator = 'between';
}
if ($GLOBALS['db']->dbType == 'oci8' && isset($parms['query_type']) && $parms['query_type'] == 'case_insensitive') {
$db_field = 'upper(' . $db_field . ")";
$field_value = strtoupper($field_value);
}
$itr++;
if (!empty($where)) {
$where .= " OR ";
}
switch ($operator) {
case 'subquery':
$in = 'IN';
if (isset($parms['subquery_in_clause'])) {
if (!is_array($parms['subquery_in_clause'])) {
$in = $parms['subquery_in_clause'];
} elseif (isset($parms['subquery_in_clause'][$field_value])) {
$in = $parms['subquery_in_clause'][$field_value];
}
}
$sq = $parms['subquery'];
if (is_array($sq)) {
$and_or = ' AND ';
if (isset($sq['OR'])) {
$and_or = ' OR ';
}
$first = true;
foreach ($sq as $q) {
if (empty($q) || strlen($q) < 2) {
continue;
}
if (!$first) {
$where .= $and_or;
}
$where .= " {$db_field} {$in} ({$q} '{$field_value}%') ";
$first = false;
}
} elseif (!empty($parms['query_type']) && $parms['query_type'] == 'format') {
$stringFormatParams = array(0 => $field_value, 1 => $GLOBALS['current_user']->id);
$where .= "{$db_field} {$in} (" . string_format($parms['subquery'], $stringFormatParams) . ")";
} else {
$where .= "{$db_field} {$in} ({$parms['subquery']} '{$field_value}%')";
}
break;
case 'like':
$where .= $db_field . " like '" . $field_value . $like_char . "'";
break;
case 'in':
$where .= $db_field . " in (" . $field_value . ')';
break;
case '=':
$where .= $db_field . " = '" . $field_value . "'";
break;
case 'db_date':
if (preg_match('/^\\d{4}.\\d{1,2}$/', $field_value) == 0) {
$where .= $db_field . " = " . $field_value;
} else {
// Create correct date_format conversion String
if ($GLOBALS['db']->dbType == 'oci8') {
$where .= db_convert($db_field, 'date_format', array("'YYYY-MM'")) . " = '" . $field_value . "'";
} else {
$where .= db_convert($db_field, 'date_format', array("'%Y-%m'")) . " = '" . $field_value . "'";
}
}
break;
case 'between':
$field_value = explode('<>', $field_value);
$where .= $db_field . " >= '" . $field_value[0] . "' AND " . $db_field . " <= '" . $field_value[1] . "'";
break;
}
}
}
if (!empty($where)) {
if ($itr > 1) {
array_push($where_clauses, '( ' . $where . ' )');
} else {
array_push($where_clauses, $where);
}
}
}
}
return $where_clauses;
}