function CalculateAlgorithm($user_id) { $rows = ExecuteQuery("SELECT\n *\n FROM\n algorithm s\n WHERE\n id = 1"); //var_dump($rows); $data = array('hot_tip' => 'Guillermo to win 15:30', 'advert' => 'Win an iPad', 'teaser' => '15/1 Odds on favourite'); return $data; }
public function saveStateCreation($postvars) { $stringURL = str_replace(' ', '-', $postvars['display_name']); // Converts spaces to dashes $stringURL = urlencode($stringURL); $params = array(NULL, $postvars['region'], $postvars['display_name'], $stringURL); // $query = "INSERT INTO tours(id, region, thumb, title, slug, content, isfeatured) VALUES (NULL, '".$postvars['region']."', '".$postvars['thumb']."', '".$postvars['title']."', '".$postvars['slug']."', '".$postvars['content']."', ".$isfeatured.");"; $query = "INSERT INTO states(state_id, type, display_name, url_name) VALUES (NULL, '" . $postvars['region'] . "', '" . $postvars['display_name'] . "', '" . $stringURL . "');"; echo $query; $result = ExecuteQuery($query); return $result; }
function store(array $fields, array $values, $table, $where = "") { $prepareFields = ""; $prepareValues = ""; $preparebin_param; foreach ($fields as $i => $value) { $prepareFields .= $fields[$i] . ","; $prepareValues .= "?,"; $preparebin_param[] = substr(gettype($prepareValues[$i]), 0, 1); } $prepareFields = "(" . substr($prepareFields, 0, -1) . ")"; $prepareValues = "(" . substr($prepareValues, 0, -1) . ")"; $query = "insert into " . $table . $prepareFields . " values" . $prepareValues . " " . $where; echo $query; ExecuteQuery($query, $preparebin_param, $values); }
function VT520GA_picklistMigrate() { global $adb; $columnList = $adb->getColumnNames('vtiger_invoicestatus'); //fix the typo, where invoice is spelled as inovice if (in_array('inovicestatusid', $columnList)) { $sql = 'alter table vtiger_invoicestatus change inovicestatusid invoicestatusid int(19)'; ExecuteQuery($sql); } }
function LoadCompanyFeedsSettings($user_id) { $company_feeds = ExecuteQuery("SELECT \n\t\t\t\tfeed_identifier\n\t\t\tFROM\n\t\t\t\tcompany_feeds\n\t\t\tWHERE\n\t\t\t\tuser_id = {$user_id}"); //var_dump($company_templates); exit; return $company_feeds; }
<?php /*+******************************************************************************** * The contents of this file are subject to the vtiger CRM Public License Version 1.0 * ("License"); You may not use this file except in compliance with the License * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. *********************************************************************************/ require_once 'include/utils/utils.php'; //5.2.1 to 5.3.0RC database changes $adb = $_SESSION['adodb_current_object']; $conn = $_SESSION['adodb_current_object']; $migrationlog->debug("\n\nDB Changes from 5.3.0RC to 5.3.0 -------- Starts \n\n"); ExecuteQuery("UPDATE vtiger_field SET quickcreate=0 WHERE fieldname='time_start' AND tabid=" . getTabid('Calendar')); ExecuteQuery("ALTER TABLE vtiger_links ADD COLUMN handler_path VARCHAR(128) DEFAULT null"); ExecuteQuery("ALTER TABLE vtiger_links ADD COLUMN handler_class VARCHAR(32) DEFAULT null"); ExecuteQuery("ALTER TABLE vtiger_links ADD COLUMN handler VARCHAR(32) DEFAULT null"); ExecuteQuery("UPDATE vtiger_organizationdetails SET logoname='vtiger-crm-logo.gif' WHERE logoname='vtiger-crm-logo.jpg'"); ExecuteQuery("UPDATE vtiger_organizationdetails SET organizationname='vtiger Systems Pvt Ltd' WHERE organizationname='vtiger'"); $migrationlog->debug("\n\nDB Changes from 5.3.0RC to 5.3.0 -------- Ends \n\n");
{ if(f.ata.value=="") { document.getElementById("spuid").innerHTML = "Please, Enter Answer."; //alert("Please,Enter The Answer") f.ata.focus(); return false; } else return true; } </script> <?php $sql = "SELECT heading from question where question_id={$_GET['id']}"; $rows = ExecuteQuery($sql); $row = mysql_fetch_array($rows); ?> <form action="answerH.php" method="POST" onsubmit="return check(this)"> <input type="hidden" value="<?php echo $_GET["id"]; ?> " name="qid" /> <table> <tr><td><b>RE : <?php echo $row["heading"]; ?> </b></td></tr> <tr><td>Answer:</td></tr><br/> <tr><td><textarea rows="4" cols="38" name="ata"></textarea><span id='spuid' style="color: red;"></span></td></tr><br/>
function updateReportColumns($table) { global $adb; $report_update_array = array("vtiger_campaign" => "(vtiger_reportmodules.primarymodule='Potentials' OR vtiger_reportmodules.secondarymodules = 'Potentials') AND {$table}.columnname LIKE '%vtiger_campaign%'", "vtiger_vendorRel" => "{$table}.columnname LIKE '%vtiger_vendorRel%'", "vtiger_potentialRel" => "{$table}.columnname LIKE '%vtiger_potentialRel%'"); foreach ($report_update_array as $key => $where) { $query = "SELECT vtiger_report.reportid as reportid,{$table}.columnname AS columnname FROM vtiger_report INNER JOIN {$table} ON {$table}.queryid = vtiger_report.reportid INNER JOIN vtiger_reportmodules ON vtiger_reportmodules.reportmodulesid = vtiger_report.reportid WHERE {$where}"; $result = $adb->query($query); if ($adb->num_rows($result) > 0) { for ($i = 0; $i < $adb->num_rows($result); $i++) { $reportid = $adb->query_result($result, $i, "reportid"); $colname = $adb->query_result($result, $i, "columnname"); $column_array = split(":", $colname); $column = split("_", $column_array[2]); $mod_name = $column[0]; $newcolname = str_replace("{$key}", $key . "{$mod_name}", $colname); ExecuteQuery("UPDATE {$table} SET columnname = '" . $newcolname . "' WHERE queryid = " . $reportid . " AND columnname = '" . $colname . "'"); } } } $query = "SELECT vtiger_reportmodules.primarymodule as primarymodule, vtiger_report.reportid as reportid,{$table}.columnname AS columnname FROM vtiger_report INNER JOIN {$table} ON {$table}.queryid = vtiger_report.reportid INNER JOIN vtiger_reportmodules ON vtiger_reportmodules.reportmodulesid = vtiger_report.reportid WHERE {$table}.columnname LIKE 'vtiger_products%:products_description:%'"; $result = $adb->query($query); if ($adb->num_rows($result) > 0) { for ($i = 0; $i < $adb->num_rows($result); $i++) { $pri_module = $adb->query_result($result, $i, "reportid"); $reportid = $adb->query_result($result, $i, "reportid"); $colname = $adb->query_result($result, $i, "columnname"); $column_array = split(":", $colname); if ($pri_module != "Products") { $column_array[0] = 'vtiger_crmentityProducts'; $column_array[1] = 'description'; } else { $column_array[0] = 'vtiger_crmentity'; $column_array[1] = 'description'; } $newcolname = $column_array[0] . ":" . $column_array[1] . ":" . $column_array[2] . ":" . $column_array[3] . ":" . $column_array[4]; ExecuteQuery("UPDATE {$table} SET columnname = '" . $newcolname . "' WHERE queryid = " . $reportid . " AND columnname = '" . $colname . "'"); } } $query = "SELECT vtiger_reportmodules.primarymodule as primarymodule, vtiger_report.reportid as reportid,{$table}.columnname AS columnname FROM vtiger_report INNER JOIN {$table} ON {$table}.queryid = vtiger_report.reportid INNER JOIN vtiger_reportmodules ON vtiger_reportmodules.reportmodulesid = vtiger_report.reportid WHERE {$table}.columnname LIKE 'vtiger_accountPotentials%:accountname:%:account_id:%'"; $result = $adb->query($query); if ($adb->num_rows($result) > 0) { for ($i = 0; $i < $adb->num_rows($result); $i++) { $reportid = $adb->query_result($result, $i, "reportid"); $colname = $adb->query_result($result, $i, "columnname"); $column_array = split(":", $colname); $column_array[0] = 'vtiger_potential'; $column_array[1] = 'related_to'; $column_array[2] = 'Potentials_Related_To'; $column_array[3] = 'related_to'; $newcolname = $column_array[0] . ":" . $column_array[1] . ":" . $column_array[2] . ":" . $column_array[3] . ":" . $column_array[4]; ExecuteQuery("UPDATE {$table} SET columnname = '" . $newcolname . "' WHERE queryid = " . $reportid . " AND columnname = '" . $colname . "'"); } } }
function vt530_changeDataType($tableName, $columnName, $fieldName, $dataType, $typeOfData) { global $adb; $query = "UPDATE vtiger_field SET typeofdata='{$typeOfData}' WHERE tablename='{$tableName}' AND fieldname='{$fieldName}'"; ExecuteQuery($query); $filterSql = 'SELECT cvid, columnname FROM vtiger_cvcolumnlist WHERE columnname LIKE ?'; $params = array("{$tableName}:{$columnName}:{$fieldName}:%:%"); $result = $adb->pquery($filterSql, $params); $noOfRows = $adb->num_rows($result); for ($i = 0; $i < $noOfRows; ++$i) { $cvId = $adb->query_result($result, $i, 'cvid'); $columnName = $adb->query_result($result, $i, 'columnname'); $columnNameParts = explode(':', $columnName); $length = count($columnNameParts); $columnNameParts[$length - 1] = $dataType; $newColumnName = implode(':', $columnNameParts); ExecuteQuery("UPDATE vtiger_cvcolumnlist SET columnname='{$newColumnName}' WHERE cvid={$cvId} AND columnname='{$columnName}'"); } $advSql = 'SELECT cvid, columnname FROM vtiger_cvadvfilter WHERE columnname LIKE ?'; $params = array("{$tableName}:{$columnName}:{$fieldName}:%:%"); $result = $adb->pquery($advSql, $params); $noOfRows = $adb->num_rows($result); for ($i = 0; $i < $noOfRows; ++$i) { $cvId = $adb->query_result($result, $i, 'cvid'); $columnName = $adb->query_result($result, $i, 'columnname'); $columnNameParts = explode(':', $columnName); $length = count($columnNameParts); $columnNameParts[$length - 1] = $dataType; $newColumnName = implode(':', $columnNameParts); ExecuteQuery("UPDATE vtiger_cvadvfilter SET columnname='{$newColumnName}' WHERE cvid={$cvId} AND columnname='{$columnName}'"); } $reportSql = 'SELECT queryid, columnname FROM vtiger_relcriteria WHERE columnname LIKE ?'; $params = array("%:{$columnName}:%:{$fieldName}:%"); $result = $adb->pquery($reportSql, $params); $noOfRows = $adb->num_rows($result); for ($i = 0; $i < $noOfRows; ++$i) { $queryId = $adb->query_result($result, $i, 'queryid'); $columnName = $adb->query_result($result, $i, 'columnname'); $columnNameParts = explode(':', $columnName); $length = count($columnNameParts); $columnNameParts[$length - 1] = $dataType; $newColumnName = implode(':', $columnNameParts); ExecuteQuery("UPDATE vtiger_relcriteria SET columnname='{$newColumnName}' WHERE queryid={$queryId} AND columnname='{$columnName}'"); } $reportSql = 'SELECT reportid, columnname FROM vtiger_reportsortcol WHERE columnname LIKE ?'; $params = array("%:{$columnName}:%:{$fieldName}:%"); $result = $adb->pquery($reportSql, $params); $noOfRows = $adb->num_rows($result); for ($i = 0; $i < $noOfRows; ++$i) { $queryId = $adb->query_result($result, $i, 'reportid'); $columnName = $adb->query_result($result, $i, 'columnname'); $columnNameParts = explode(':', $columnName); $length = count($columnNameParts); $columnNameParts[$length - 1] = $dataType; $newColumnName = implode(':', $columnNameParts); ExecuteQuery("UPDATE vtiger_reportsortcol SET columnname='{$newColumnName}' WHERE queryid={$queryId} AND columnname='{$columnName}'"); } $reportSql = 'SELECT queryid, columnname FROM vtiger_selectcolumn WHERE columnname LIKE ?'; $params = array("%:{$columnName}:%:{$fieldName}:%"); $result = $adb->pquery($reportSql, $params); $noOfRows = $adb->num_rows($result); for ($i = 0; $i < $noOfRows; ++$i) { $queryId = $adb->query_result($result, $i, 'queryid'); $columnName = $adb->query_result($result, $i, 'columnname'); $columnNameParts = explode(':', $columnName); $length = count($columnNameParts); $columnNameParts[$length - 1] = $dataType; $newColumnName = implode(':', $columnNameParts); ExecuteQuery("UPDATE vtiger_selectcolumn SET columnname='{$newColumnName}' WHERE queryid={$queryId} AND columnname='{$columnName}'"); } }
function LoadCompanies() { $users = ExecuteQuery("SELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tcompanies\n\t\t\tORDER BY\n\t\t\t\tname"); return $users; }
ExecuteQuery("ALTER TABLE vtiger_users2group Type=InnoDB"); ExecuteQuery("ALTER TABLE vtiger_users_last_import Type=InnoDB"); ExecuteQuery("ALTER TABLE vtiger_wordtemplates Type=InnoDB"); ExecuteQuery("ALTER TABLE vtiger_activsubtype Type=InnoDB"); ExecuteQuery("ALTER TABLE vtiger_version Type=InnoDB"); //Added by Asha for tickets #4513 ////File Name field size increased into 255 chars in vtiger_attachments table ExecuteQuery("alter table vtiger_attachments change name name varchar(255)"); ////Data type for File Path field changed to TEXT in vtiger_attachments table ExecuteQuery("alter table vtiger_attachments change path path TEXT"); //Added by bharathi #4657 ExecuteQuery("alter table vtiger_attachments drop index attachments_description_name_type_attachmentsid_idx"); ExecuteQuery("alter table vtiger_attachments add index attachments_description_type_attachmentsid_idx (`description`,`type`,`attachmentsid`)"); //Added by Asha for ticket #4724 ExecuteQuery("update vtiger_selectcolumn set columnname = 'vtiger_campaign:campaignname:Potentials_Campaign_Source:campaignid:V' where columnname = 'vtiger_potential:campaignid:Potentials_Campaign_Source:campaignid:V'"); //Added by bharathi for #4590 on dec 21-2007 ExecuteQuery("alter table vtiger_potential change column amount amount decimal(14,2) default '0.00'"); //Added by Srini for #4684 on dec 21-2007 ExecuteQuery("update vtiger_field set uitype=19 where fieldname='update_log' and tablename='vtiger_troubletickets'"); //In 503 we are using <br> tags for line breaks in Inventory Notification mails. In 504 it is not necessary. //this code will get the contents from db and then convert all <br> character with \n and again update in db. $result = $adb->query("select notificationid,notificationbody from vtiger_inventorynotification"); for ($i = 0; $i < $adb->num_rows($result); $i++) { $body = decode_html($adb->query_result($result, $i, 'notificationbody')); $body = str_replace('<br>', '\\n', $body); $notificationid = $adb->query_result($result, $i, 'notificationid'); $adb->pquery("update vtiger_inventorynotification set notificationbody=? where notificationid=?", array($body, $notificationid)); } //Added by Asha for #4826 ExecuteQuery("update vtiger_pricebook set active=0 where active is null"); $migrationlog->debug("\n\nDB Changes from 5.0.3 to 5.0.4 RC-------- Ends \n\n");
//Added to rearange the attachment in HelpDesk ExecuteQuery(" update vtiger_field set block=25,sequence=12 where tabid=13 and fieldname='filename'"); //Query added to as entityname,its tablename,its primarykey are saved in a table ExecuteQuery(" CREATE TABLE `vtiger_entityname` (\n\t`tabid` int(19) NOT NULL default '0',\n\t`modulename` varchar(50) NOT NULL,\n\t`tablename` varchar(50) NOT NULL,\n\t`fieldname` varchar(150) NOT NULL,\n\t`entityidfield` varchar(150) NOT NULL,\n\tPRIMARY KEY (`tabid`),\n\tKEY `entityname_tabid_idx` (`tabid`)\n)"); //Data Populated for the existing modules ExecuteQuery("insert into vtiger_entityname values(7,'Leads','vtiger_leaddetails','lastname,firstname','leadid')"); ExecuteQuery("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid')"); ExecuteQuery("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','lastname,firstname','contactid')"); ExecuteQuery("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid')"); ExecuteQuery("insert into vtiger_entityname values(8,'Notes','vtiger_notes','title','notesid')"); ExecuteQuery("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid')"); ExecuteQuery("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid')"); ExecuteQuery("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid')"); ExecuteQuery("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid')"); ExecuteQuery("insert into vtiger_entityname values(29,'Users','vtiger_users','last_name,first_name','id')"); ExecuteQuery("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid')"); ExecuteQuery("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid')"); ExecuteQuery("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid')"); ExecuteQuery("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid')"); ExecuteQuery("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid')"); ExecuteQuery("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid')"); ExecuteQuery("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid')"); ExecuteQuery("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id')"); //added quantity in stock in product default listview - All $res = $adb->query("select vtiger_cvcolumnlist.cvid from vtiger_cvcolumnlist inner join vtiger_customview on vtiger_cvcolumnlist.cvid=vtiger_customview.cvid where entitytype='Products' and viewname='All'"); if ($adb->num_rows != 0) { $cvid = $adb->query_result($res, 0, 'cvid'); $adb->query("insert into vtiger_cvcolumnlist values({$cvid},5,'vtiger_products:qtyinstock:qtyinstock:Products_Quantity_In_Stock:V')"); } //echo "<br><font color='red'> 5.0/5.0.1 ==> 5.0.2 Database changes has been done.</font><br>"; $migrationlog->debug("\n\nDB Changes from 5.0.1 to 5.0.2 -------- Ends \n\n");
* The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. *********************************************************************************/ //5.1.0 RC to 5.1.0 database changes //we have to use the current object (stored in PatchApply.php) to execute the queries $adb = $_SESSION['adodb_current_object']; $conn = $_SESSION['adodb_current_object']; $migrationlog->debug("\n\nDB Changes from 5.1.0 RC to 5.1.0 -------- Starts \n\n"); ExecuteQuery("DELETE vtiger_cvcolumnlist FROM vtiger_cvcolumnlist INNER JOIN vtiger_customview WHERE vtiger_cvcolumnlist.columnname LIKE '%vtiger_notes:filename%' AND vtiger_customview.cvid = vtiger_cvcolumnlist.cvid AND vtiger_customview.entitytype='HelpDesk'"); ExecuteQuery("DELETE vtiger_cvcolumnlist FROM vtiger_cvcolumnlist INNER JOIN vtiger_customview WHERE (vtiger_cvcolumnlist.columnname LIKE '%parent_id%' OR vtiger_cvcolumnlist.columnname LIKE '%vtiger_contactdetails%') AND vtiger_customview.cvid = vtiger_cvcolumnlist.cvid AND vtiger_customview.entitytype='Documents'"); ExecuteQuery("DELETE vtiger_cvadvfilter FROM vtiger_cvadvfilter INNER JOIN vtiger_customview WHERE vtiger_cvadvfilter.columnname LIKE '%vtiger_notes:filename%' AND vtiger_customview.cvid = vtiger_cvadvfilter.cvid AND vtiger_customview.entitytype='HelpDesk'"); ExecuteQuery("DELETE vtiger_cvadvfilter FROM vtiger_cvadvfilter INNER JOIN vtiger_customview WHERE (vtiger_cvadvfilter.columnname LIKE '%parent_id%' OR vtiger_cvadvfilter.columnname LIKE '%vtiger_contactdetails%') AND vtiger_customview.cvid = vtiger_cvadvfilter.cvid AND vtiger_customview.entitytype='Documents'"); // Fixed issue with Calendar duration calculation ExecuteQuery("ALTER TABLE vtiger_activity MODIFY duration_hours VARCHAR(200)"); $result = $adb->query("SELECT activityid,date_start,due_date, time_start,time_end FROM vtiger_activity WHERE activitytype NOT IN ('Task','Emails')"); $noofrows = $adb->num_rows($result); for ($index = 0; $index < $noofrows; $index++) { $activityid = $adb->query_result($result, $index, 'activityid'); $date_start = $adb->query_result($result, $index, 'date_start'); $time_start = $adb->query_result($result, $index, 'time_start'); $due_date = $adb->query_result($result, $index, 'due_date'); $time_end = $adb->query_result($result, $index, 'time_end'); $start_date = split("-", $date_start); $end_date = split("-", $due_date); $start_time = split(":", $time_start); $end_time = split(":", $time_end); $start = mktime(intval($start_time[0]), intval($start_time[1]), 0, intval($start_date[1]), intval($start_date[2]), intval($start_date[0])); $end = mktime(intval($end_time[0]), intval($end_time[1]), 0, intval($end_date[1]), intval($end_date[2]), intval($end_date[0])); $duration_in_minutes = floor(($end - $start) / 60);
require "checkUser.php"; $id = $_GET["id"]; ?> <a href="question.php?stid=<?php echo $id; ?> ">Ask Question<img src="res/images/askq.jpg" class='imagedel'/></a> <hr /> <?php $str = "SELECT * FROM question, user WHERE question.user_id=user.user_id and subtopic_id={$id}"; $result = ExecuteQuery($str); $no_rows = mysql_num_rows($result); if ($no_rows > 0) { while ($row = mysql_fetch_array($result)) { $rowsc = ExecuteQuery("SELECT count(*) as counter from answer where question_id={$row['question_id']}"); $rowc = mysql_fetch_array($rowsc); $count = $rowc['counter']; echo "<h4>"; echo "<span class='box2'>"; echo "<span class='head'><a href='questionview.php?qid={$row['question_id']}' >{$row['heading']}</a> </span>"; echo "</span>"; echo "</h4>"; echo "{$row['question_detail']} <span class='view2'>Views : {$row['views']}, Replies :{$count}</span>"; echo "<br/><br/>"; echo "Asked by<br/>{$row['fullname']}"; echo "<br/><div class='line'></div>"; //echo "<a href='answer.php?qid=$row[question_id]' class='reply'>REPLY</a>"; } } else { echo "No questions at the moment";
<?php require "header.php"; ?> <?php $result = ExecuteQuery("SELECT * FROM User"); echo "<table border='1'>"; echo "<strong><tr><th>firstname</th><th>fullname</th><th>password</th><th>e_mail</th><th>gender</th><th>dob</th></tr></strong>"; while ($name_row = mysql_fetch_row($result)) { echo "<tr>"; print "<td>{$name_row[0]}</td><td>{$name_row[1]}</td><td>{$name_row[2]}</td><td>{$name_row[3]}</td><td>{$name_row[4]}</td><td>{$name_row[5]}</td><br />"; echo "</tr>"; } require "footer.php";
ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=Settings&action=MailScanner&parenttab=Settings' where name = 'LBL_MAIL_SCANNER'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=com_vtiger_workflow&action=workflowlist&parenttab=Settings' where name = 'LBL_LIST_WORKFLOWS'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=Settings&action=MenuEditor&parenttab=Settings' where name = 'LBL_MENU_EDITOR'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=com_vtiger_workflow&action=workflowlist' where name = 'LBL_WORKFLOW_LIST'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=ConfigEditor&action=index', description='Update configuration file of the application' where name = 'Configuration Editor' or name = 'LBL_CONFIG_EDITOR'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=ModTracker&action=BasicSettings&parenttab=Settings&formodule=ModTracker' where name = 'ModTracker'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=CustomerPortal&action=index&parenttab=Settings' where name = 'LBL_CUSTOMER_PORTAL'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=Webforms&action=index&parenttab=Settings', description='Allows you to manage Webforms' where name = 'Webforms'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=CronTasks&action=ListCronJobs&parenttab=Settings', description='Allows you to Configure Cron Task' where name = 'Scheduler'"); ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=Tooltip&action=QuickView&parenttab=Settings' where name = 'LBL_TOOLTIP_MANAGEMENT'"); //Delete new Blocks in Calendar ExecuteQuery("UPDATE vtiger_blocks SET blocklabel = '' WHERE blocklabel = 'LBL_DESCRIPTION_INFORMATION' AND tabid = '9'"); ExecuteQuery("UPDATE vtiger_blocks SET blocklabel = '' WHERE blocklabel = 'LBL_DESCRIPTION_INFORMATION' AND tabid = '16'"); ExecuteQuery("UPDATE vtiger_blocks SET blocklabel = '' WHERE blocklabel = 'LBL_REMINDER_INFORMATION' AND tabid = 16"); ExecuteQuery("UPDATE vtiger_field SET block = '41' WHERE tabid = '16' and fieldname NOT IN('reminder_time','contact_id')"); ExecuteQuery("UPDATE vtiger_field SET block = '19' WHERE tabid = '16' and fieldname = 'contact_id'"); // Change HelpDesk Workflows global $adb; $workflowManager = new VTWorkflowManager($adb); $taskManager = new VTTaskManager($adb); $wfrs = $adb->query("SELECT workflow_id,summary FROM com_vtiger_workflows WHERE module_name='HelpDesk'"); while ($wfid = $adb->fetch_array($wfrs)) { deleteWorkflow($wfid['workflow_id']); putMsg('Workflow "' . $wfid['summary'] . '" deleted!'); } // Trouble Tickets workflow on creation from Customer Portal $helpDeskWorkflow = $workflowManager->newWorkFlow("HelpDesk"); $helpDeskWorkflow->test = '[{"fieldname":"from_portal","operation":"is","value":"true:boolean"}]'; $helpDeskWorkflow->description = "Workflow for Ticket Created from Portal"; $helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_FIRST_SAVE; $helpDeskWorkflow->defaultworkflow = 1;
<hr/> <?php //first fetch whom u have send chats $sql = "SELECT chat_id, user_id_from, user_id_to, fullname FROM Chatmaster, user WHERE chatmaster.user_id_to=user.user_id AND chatmaster.user_id_from={$_SESSION['uid']} "; $rows = ExecuteQuery($sql); while ($row = mysql_fetch_array($rows)) { echo "<a href='readmsg.php?id={$row['chat_id']}'>{$row['fullname']}</a>"; $chatrow = mysql_fetch_array(ExecuteQuery("SELECT * FROM chat WHERE chat_id={$row['chat_id']} ORDER BY cdatetime DESC")); if ($chatrow) { echo "<br/><br/> {$chatrow['message']}<br/>"; echo "{$chatrow['cdatetime']}"; } echo "<hr style='border-top:1px solid #c3c3c3; border-bottom:1px solid white'/>"; } // now fetch those that have sent chats to you $sql = "SELECT chat_id, user_id_from, user_id_to, fullname FROM Chatmaster, user WHERE chatmaster.user_id_from=user.user_id AND chatmaster.user_id_to={$_SESSION['uid']}"; $rows = ExecuteQuery($sql); while ($row = mysql_fetch_array($rows)) { echo "<a href='readmsg.php?id={$row['chat_id']}'>{$row['fullname']}</a>"; $chatrow = mysql_fetch_array(ExecuteQuery("SELECT * FROM chat WHERE chat_id={$row['chat_id']} ORDER BY cdatetime DESC")); if ($chatrow) { echo "<br/><br/> {$chatrow['message']}<br/>"; echo "{$chatrow['cdatetime']}"; } echo "<hr style='border-top:1px solid #c3c3c3; border-bottom:1px solid white'/>"; } ?> <?php require "footer.php";
ExecuteQuery("update vtiger_cvadvfilter set columnname='vtiger_purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:V' where columnname='vtiger_purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:I'"); //Purchase Order - Due Date ExecuteQuery("update vtiger_cvcolumnlist set columnname='vtiger_purchaseorder:duedate:duedate:PurchaseOrder_Due_Date:D' where columnname='vtiger_purchaseorder:duedate:duedate:PurchaseOrder_Due_Date:V'"); ExecuteQuery("update vtiger_cvadvfilter set columnname='vtiger_purchaseorder:duedate:duedate:PurchaseOrder_Due_Date:D' where columnname='vtiger_purchaseorder:duedate:duedate:PurchaseOrder_Due_Date:V'"); //SalesOrder - Potential Name ExecuteQuery("update vtiger_cvcolumnlist set columnname='vtiger_salesorder:potentialid:potential_id:SalesOrder_Potential_Name:V' where columnname='vtiger_salesorder:potentialid:potential_id:SalesOrder_Potential_Name:I'"); ExecuteQuery("update vtiger_cvadvfilter set columnname='vtiger_salesorder:potentialid:potential_id:SalesOrder_Potential_Name:V' where columnname='vtiger_salesorder:potentialid:potential_id:SalesOrder_Potential_Name:I'"); //SalesOrder - Quote Name ExecuteQuery("update vtiger_cvcolumnlist set columnname='vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:V' where columnname='vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:I'"); ExecuteQuery("update vtiger_cvadvfilter set columnname='vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:V' where columnname='vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:I'"); //Products Related To field deleted from vtiger_selectcolumn ExecuteQuery("delete from vtiger_selectcolumn where columnname ='vtiger_seproductsrel:crmid:Products_Related_To:parent_id:I'"); //cvstdfilter table is in MyISAM engine so that the order of diplay will not be same in all time $adb->query("alter table vtiger_cvstdfilter engine=InnoDB"); //we have to set set permission as 3 in vtiger_def_org_share as the Calendar is private ExecuteQuery("update vtiger_def_org_share set permission=3 where tabid=16"); //Query added to delete custom field entries available only in field table and not in customfield tables $customtables_array = array('vtiger_accountscf', 'vtiger_campaignscf', 'vtiger_contactscf', 'vtiger_invoicecf', 'vtiger_leadscf', 'vtiger_potentialscf', 'vtiger_pricebookcf', 'vtiger_productcf', 'vtiger_purchaseordercf', 'vtiger_quotescf', 'vtiger_salesordercf', 'vtiger_ticketcf', 'vtiger_vendorcf'); foreach ($customtables_array as $customfieldtable) { $sql = "select fieldname,tablename,columnname,fieldid from vtiger_field where tablename='{$customfieldtable}'"; $result = $adb->query($sql); $columns = $adb->getColumnNames($customfieldtable); for ($i = 0; $i < $adb->num_rows($result); $i++) { $columnname = $adb->query_result($result, $i, 'columnname'); if (!in_array($columnname, $columns)) { $fieldID = $adb->query_result($result, $i, 'fieldid'); $query = "delete from vtiger_field where fieldid=" . $fieldID; $result1 = $adb->query($query); } } }
function VT520_fieldCleanUp() { $db = PearDatabase::getInstance(); $result = $db->pquery("SELECT fieldid,typeofdata FROM vtiger_field WHERE fieldname = " . "'birthday' AND tabid = '" . getTabid('Contacts') . "'", array()); $fieldId = $db->query_result($result, 0, 'fieldid'); $typeOfData = $db->query_result($result, 0, 'typeofdata'); $typeInfo = explode('~', $typeOfData); $mandatory = $typeInfo[1]; ExecuteQuery("update vtiger_field set typeofdata='D~{$mandatory}' where fieldid={$fieldId}"); $result = $db->pquery("SELECT fieldid,typeofdata FROM vtiger_field WHERE fieldname = " . "'eventstatus' AND tabid = '" . getTabid('Calendar') . "'", array()); $fieldId = $db->query_result($result, 0, 'fieldid'); $typeOfData = $db->query_result($result, 0, 'typeofdata'); $typeInfo = explode('~', $typeOfData); $type = $typeInfo[0]; ExecuteQuery("update vtiger_field set typeofdata='{$type}~O' where fieldid={$fieldId}"); }
public function CalcRunPoints($age, $runmin, $runsec) { $agegroup = $this->CalcAgeGroup($age); $col = "a" . $agegroup; $query = "select {$col} from run where repetition='" . trim($runmin) . ":" . trim($runsec) . "'"; $result = ExecuteQuery($query); if ($result[0] && $result[1]->RecordCount() > 0 && ($row = $result[1]->FetchRow())) { return $row[0]; } else { return 0; } }
function deleteWorkflow($wfid) { ExecuteQuery("DELETE FROM com_vtiger_workflowtasks WHERE workflow_id = {$wfid}"); ExecuteQuery("DELETE FROM com_vtiger_workflows WHERE workflow_id = {$wfid}"); }
<hr> <p><i class="fa fa-clock-o"></i> Posted on August 24, 2013 at 9:00 PM by <a href="#">Start Boostrap</a></p> <hr> <hr> <!-- the comment box --> <div class="well"> <?php $message = ''; if (isset($_POST['submit'])) { $result = ExecuteQuery("INSERT INTO links\r\n (OriginalLink, ShortenLink, Title, Enable, Visits)\r\n VALUES(\r\n '{$_POST['txtOriginalLink']}'\r\n , 'http://www.{$domain_name}/?{$_POST['txtNewLink']}'\r\n , '{$_POST['txtTitle']}'\r\n , '1'\r\n , '0'\r\n \r\n ) \r\n "); if ($result) { $message = "<p>Your Linke Created Successfully.</p>"; $message .= "<p>Original Link: " . $_POST['txtOriginalLink'] . '</p>'; $message .= "Shorten Link: " . "<a href='http://www.{$domain_name}/?q={$_POST['txtNewLink']}'>{$_POST['txtTitle']}</a>"; } } ?> <h4>Enter Yor Link Here:</h4> <form role="form" action="" method="POST"> <div class="form-group"> <input placeholder="Original Link" type="text" class="form-control" rows="3" name="txtOriginalLink" /> </div> <div class="form-group">
function migrate($migrationInfo) { global $installationStrings; $completed = false; set_time_limit(0); //ADDED TO AVOID UNEXPECTED TIME OUT WHILE MIGRATING global $dbconfig; require $migrationInfo['root_directory'] . '/config.inc.php'; $dbtype = $dbconfig['db_type']; $host = $dbconfig['db_server'] . $dbconfig['db_port']; $dbname = $dbconfig['db_name']; $username = $dbconfig['db_username']; $passwd = $dbconfig['db_password']; global $adb, $migrationlog; $adb = new PearDatabase($dbtype, $host, $dbname, $username, $passwd); $query = " ALTER DATABASE " . $adb->escapeDbName($dbname) . " DEFAULT CHARACTER SET utf8"; $adb->query($query); $source_directory = $migrationInfo['source_directory']; if (file_exists($source_directory . 'user_privileges/CustomInvoiceNo.php')) { require_once $source_directory . 'user_privileges/CustomInvoiceNo.php'; } $migrationlog =& LoggerManager::getLogger('MIGRATION'); if (isset($migrationInfo['old_version'])) { $source_version = $migrationInfo['old_version']; } if (!isset($source_version) || empty($source_version)) { //If source version is not set then we cannot proceed echo "<br> " . $installationStrings['LBL_SOURCE_VERSION_NOT_SET']; exit; } $reach = 0; include $migrationInfo['root_directory'] . "/modules/Migration/versions.php"; foreach ($versions as $version => $label) { if ($version == $source_version || $reach == 1) { $reach = 1; $temp[] = $version; } } $temp[] = $current_version; global $adb, $dbname; $_SESSION['adodb_current_object'] = $adb; @ini_set('zlib.output_compression', 0); @ini_set('output_buffering', 'off'); ob_implicit_flush(true); echo '<table width="98%" border="1px" cellpadding="3" cellspacing="0" height="100%">'; if (is_array($_SESSION['migration_info']['user_messages'])) { foreach ($_SESSION['migration_info']['user_messages'] as $infoMap) { echo "<tr><td>" . $infoMap['status'] . "</td><td>" . $infoMap['msg'] . "</td></tr>"; } } echo "<tr><td colspan='2'><b>{$installationStrings['LBL_GOING_TO_APPLY_DB_CHANGES']}...</b></td></tr>"; for ($patch_count = 0; $patch_count < count($temp); $patch_count++) { //Here we have to include all the files (all db differences for each release will be included) $filename = "modules/Migration/DBChanges/" . $temp[$patch_count] . "_to_" . $temp[$patch_count + 1] . ".php"; $empty_tag = "<tr><td colspan='2'> </td></tr>"; $start_tag = "<tr><td colspan='2'><b><font color='red'> "; $end_tag = "</font></b></td></tr>"; if (is_file($filename)) { echo $empty_tag . $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_STARTS'] . "." . $end_tag; include $filename; //include the file which contains the corresponding db changes echo $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_ENDS'] . "." . $end_tag; } } /* Install Vtlib Compliant Modules */ Common_Install_Wizard_Utils::installMandatoryModules(); Migration_Utils::installOptionalModules($migrationInfo['selected_optional_modules'], $migrationInfo['source_directory'], $migrationInfo['root_directory']); Migration_utils::copyLanguageFiles($migrationInfo['source_directory'], $migrationInfo['root_directory']); //Here we have to update the version in table. so that when we do migration next time we will get the version $res = $adb->query('SELECT * FROM vtiger_version'); global $vtiger_current_version; require $migrationInfo['root_directory'] . '/vtigerversion.php'; if ($adb->num_rows($res)) { $res = ExecuteQuery("UPDATE vtiger_version SET old_version='{$versions[$source_version]}',current_version='{$vtiger_current_version}'"); $completed = true; } else { ExecuteQuery("INSERT INTO vtiger_version (id, old_version, current_version) values (" . $adb->getUniqueID('vtiger_version') . ", '{$versions[$source_version]}', '{$vtiger_current_version}');"); $completed = true; } echo '</table><br><br>'; create_tab_data_file(); create_parenttab_data_file(); return $completed; }
<?php session_start(); require "utility.php"; require "header.php"; //require("checkUser.php"); $uid = $_GET['id']; $qry = "DELETE FROM subtopic WHERE subtopic_id='" . $uid . "'"; $result = ExecuteQuery($qry); if ($result) { header("location:subtopic.php"); } else { echo "Not Done"; } require "footer.php";
<?php /************************************************************************************************* * Copyright 2016 JPL TSolucio, S.L. -- This file is a part of TSOLUCIO coreBOS Customizations. * Licensed under the vtiger CRM Public License Version 1.1 (the "License"); you may not use this * file except in compliance with the License. You can redistribute it and/or modify it * under the terms of the License. JPL TSolucio, S.L. reserves all rights not expressly * granted by the License. coreBOS distributed by JPL TSolucio S.L. is distributed in * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Unless required by * applicable law or agreed to in writing, software distributed under the License is * distributed on an "AS IS" BASIS, WITHOUT ANY WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing * permissions and limitations under the License. You may obtain a copy of the License * at <http://corebos.org/documentation/doku.php?id=en:devel:vpl11> ************************************************************************************************* * Migrate from vtiger CRM 6.3 to vtiger CRM 6.2 * Version : 1.0 * Author : JPL TSolucio, S. L. *************************************************************************************************/ $pbtab = getTabid('PriceBooks'); $wsapptab = getTabid('WSAPP'); ExecuteQuery("delete from vtiger_profile2utility where tabid in ({$pbtab},{$wsapptab})"); ExecuteQuery("update vtiger_version set old_version='6.1.0', current_version='6.2.0' where id=1");
ExecutePQuery($update_mapping, array(getFieldid($leadTab, 'lastname'), 0, getFieldid($contactTab, 'lastname'), 0)); } else { ExecutePQuery($insert_mapping, array(getFieldid($leadTab, 'lastname'), null, getFieldid($contactTab, 'lastname'), null, 0)); } $productInstance = Vtiger_Module::getInstance('Products'); $serviceInstance = Vtiger_Module::getInstance('Services'); /* Replace 'Handler' field with 'Assigned to' field for Products and Services - starts */ ExecuteQuery("UPDATE vtiger_crmentity, vtiger_products SET vtiger_crmentity.smownerid = vtiger_products.handler WHERE vtiger_crmentity.crmid = vtiger_products.productid"); ExecuteQuery("ALTER TABLE vtiger_products DROP COLUMN handler"); ExecutePQuery("UPDATE vtiger_field SET columnname = 'smownerid', tablename = 'vtiger_crmentity', uitype = '53', typeofdata = 'V~M', info_type = 'BAS', quickcreate = 0, quickcreatesequence = 5\r\n\t\t\t\tWHERE columnname = 'handler' AND tablename = 'vtiger_products' AND tabid = ?", array($productsTabId)); $oldProductHandlerColumnName = 'vtiger_products:handler:assigned_user_id:Products_Handler:V'; $newProductHandlerColumnName = 'vtiger_crmentity:smownerid:assigned_user_id:Products_Handler:V'; ExecutePQuery("UPDATE vtiger_cvcolumnlist SET columnname=? WHERE columnname=?", array($newProductHandlerColumnName, $oldProductHandlerColumnName)); ExecutePQuery("UPDATE vtiger_cvadvfilter SET columnname=? WHERE columnname=?", array($newProductHandlerColumnName, $oldProductHandlerColumnName)); ExecuteQuery("UPDATE vtiger_crmentity, vtiger_service SET vtiger_crmentity.smownerid = vtiger_service.handler WHERE vtiger_crmentity.crmid = vtiger_service.serviceid"); ExecuteQuery("ALTER TABLE vtiger_service DROP COLUMN handler"); ExecutePQuery("UPDATE vtiger_field SET columnname = 'smownerid', tablename = 'vtiger_crmentity', uitype = '53', typeofdata = 'V~M', info_type = 'BAS', quickcreate = 0, quickcreatesequence = 4\r\n\t\t\t\tWHERE columnname = 'handler' AND tablename = 'vtiger_service' AND tabid = ?", array($servicesTabId)); $oldServiceOwnerColumnName = 'vtiger_service:handler:assigned_user_id:Services_Owner:V'; $newServiceOwnerColumnName = 'vtiger_crmentity:smownerid:assigned_user_id:Services_Owner:V'; ExecutePQuery("UPDATE vtiger_cvcolumnlist SET columnname=? WHERE columnname=?", array($newServiceOwnerColumnName, $oldServiceOwnerColumnName)); ExecutePQuery("UPDATE vtiger_cvadvfilter SET columnname=? WHERE columnname=?", array($newServiceOwnerColumnName, $oldServiceOwnerColumnName)); // Allow Sharing access and role-based security for Products and Services Vtiger_Access::deleteSharing($productInstance); Vtiger_Access::initSharing($productInstance); Vtiger_Access::allowSharing($productInstance); Vtiger_Access::setDefaultSharing($productInstance); Vtiger_Access::deleteSharing($serviceInstance); Vtiger_Access::initSharing($serviceInstance); Vtiger_Access::allowSharing($serviceInstance); Vtiger_Access::setDefaultSharing($serviceInstance); Vtiger_Module::syncfile();
<?php session_start(); require "header.php"; require "checkUser.php"; $uto = $_POST['uto']; $tt = $_POST['tt']; $sql = "INSERT INTO chatmaster (user_id_from,user_id_to) values ({$_SESSION['uid']},{$uto})"; $result = ExecuteNonQuery($sql); $sql = "SELECT MAX(chat_id) as cid FROM chatmaster"; $row = mysql_fetch_array(ExecuteQuery($sql)); $cid = $row['cid']; $sql = "INSERT INTO chat (user_id, chat_id, message) values ({$_SESSION['uid']},{$cid},'{$tt}')"; $result += ExecuteNonQuery($sql); if ($result == 2) { header("location:messaged.php"); } require "footer.php";
<?php include "include/bootstrap.php"; if (isset($_GET['q'])) { $q = $_GET['q']; echo "SELECT * FROM links WHERE ID = '{$q}'"; $result = ExecuteQuery("SELECT * FROM links WHERE ID = '{$q}'"); $goto = mysqli_fetch_assoc($result); if ($result) { ExecuteQuery("UPDATE links SET Visits= (Visits + 1) WHERE ID = '{$q}'"); // echo 'location: ' . $goto['OriginalLink']; header('location: ' . $goto['OriginalLink']); } }
while ($row = mysql_fetch_array($result)) { $head = $row['heading']; echo "<h4>"; echo $head; echo "</h4>"; echo "<span class='box2'>"; echo "<span class='head'><a href='answer.php?id={$_GET['qid']}'>REPLY</a></span>"; echo "<table>"; echo "<tr><td valign='top' width='100px'>\n\t\t\t\t<img src='{$row['uimg']}' alt='' class='uimg'/>\n\t\t\t\t<br/>\n\t\t\t{$row['fullname']}\n\t\t\t<td valign='top'>\n\t\t\t<b>{$head}</b><br/>\n\t\t\t{$row['datetime']}<br/><br/>\n\t\t\t{$row['question_detail']}</tr>"; echo "</table></span><div class='h10'></div>"; } } ?> <?php $sql = "select * from answer,user where question_id={$_GET['qid']} and answer.user_id=user.user_id ORDER BY datetime desc"; $result = ExecuteQuery($sql); $no_rows = mysql_num_rows($result); if ($no_rows > 0) { while ($row1 = mysql_fetch_array($result)) { echo "<span class='box2'>"; echo "<span class='head'><a href='answer.php?id={$_GET['qid']}'>REPLY</a><a href='like.php?id={$row1['answer_id']} ' class='view2' >Like {$row1['like']}</a> <a href='dwdpap.php?id={$_GET['qid']}' class='view2'>Download</a>\n</span>"; echo "<table>"; echo "<tr><td valign='top' width='100px'>\n\t\t\t<img src='{$row1['uimg']}' alt='' class='uimg'/>\n\t\t\t\t<br/>\n\t\t\t{$row1['fullname']}<td valign='top'><b>Re : {$head}</b><br/>{$row1['datetime']}<br/><br/>{$row1['answer_detail']}</tr>"; echo "</table></span><div class='h10'></div>"; } } ?> <?php require "footer.php";
function CheckSessionId($session_id) { $rows = ExecuteQuery("SELECT\n\t\t\t\tu.*,\n\t\t\t\tc.*\n\t\t\tFROM\n\t\t\t\tusers u\n\t\t\t\tLEFT JOIN companies c\n\t\t\t\tON c.company_id = u.company_id\n\t\t\tWHERE\n\t\t\t\tsession_id = UNHEX('{$session_id}')"); return count($rows) == 1 ? $rows[0] : false; }