本文整理汇总了PHP中PearDatabase::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP PearDatabase::num_rows方法的具体用法?PHP PearDatabase::num_rows怎么用?PHP PearDatabase::num_rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PearDatabase
的用法示例。
在下文中一共展示了PearDatabase::num_rows方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchNameList
public function fetchNameList($field, $result, $rel = null)
{
$referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList();
$fieldName = $field->getFieldName();
$rowCount = $this->db->num_rows($result);
$idList = array();
for ($i = 0; $i < $rowCount; $i++) {
if ($rel == 1) {
$modrel = getTabModuleName($field->getTabId());
$colname = strtolower($modrel) . $field->getColumnName();
} else {
$colname = $field->getColumnName();
}
$id = $this->db->query_result($result, $i, $colname);
if (!isset($this->nameList[$fieldName][$id])) {
$idList[$id] = $id;
}
}
$idList = array_keys($idList);
if (count($idList) == 0) {
return;
}
$moduleList = $referenceFieldInfoList[$fieldName];
foreach ($moduleList as $module) {
$meta = $this->queryGenerator->getMeta($module);
if ($meta->isModuleEntity()) {
if ($module == 'Users') {
$nameList = getOwnerNameList($idList);
} else {
//TODO handle multiple module names overriding each other.
$nameList = getEntityName($module, $idList);
}
} else {
$nameList = vtws_getActorEntityName($module, $idList);
}
$entityTypeList = array_intersect(array_keys($nameList), $idList);
foreach ($entityTypeList as $id) {
$this->typeList[$id] = $module;
}
if (empty($this->nameList[$fieldName])) {
$this->nameList[$fieldName] = array();
}
foreach ($entityTypeList as $id) {
$this->typeList[$id] = $module;
$this->nameList[$fieldName][$id] = $nameList[$id];
}
}
}
示例2: getPickListOptions
function getPickListOptions($fieldName)
{
$default_charset = VTWS_PreserveGlobal::getGlobal('default_charset');
$options = array();
$sql = "select * from vtiger_picklist where name=?";
$result = $this->pearDB->pquery($sql, array($fieldName));
$numRows = $this->pearDB->num_rows($result);
if ($numRows == 0) {
$sql = "select * from vtiger_{$fieldName}";
$result = $this->pearDB->pquery($sql, array());
$numRows = $this->pearDB->num_rows($result);
for ($i = 0; $i < $numRows; ++$i) {
$elem = array();
$picklistValue = $this->pearDB->query_result($result, $i, $fieldName);
$picklistValue = html_entity_decode($picklistValue, ENT_QUOTES, $default_charset);
$elem["label"] = getTranslatedString($picklistValue, $this->getMeta()->getTabName());
$elem["value"] = $picklistValue;
array_push($options, $elem);
}
} else {
$details = getPickListValues($fieldName, $this->user->roleid);
for ($i = 0; $i < sizeof($details); ++$i) {
$elem = array();
$picklistValue = html_entity_decode($details[$i], ENT_QUOTES, $default_charset);
$elem["label"] = getTranslatedString($picklistValue, $this->getMeta()->getTabName());
$elem["value"] = $picklistValue;
array_push($options, $elem);
}
}
return $options;
}
示例3: getPickListOptions
function getPickListOptions()
{
global $app_strings, $mod_strings, $log, $current_language;
static $purified_plcache = array();
$fieldName = $this->getFieldName();
$default_charset = VTWS_PreserveGlobal::getGlobal('default_charset');
$moduleName = getTabModuleName($this->getTabId());
if ($moduleName == 'Events') {
$moduleName = 'Calendar';
}
$temp_mod_strings = $moduleName != '' ? return_module_language($current_language, $moduleName) : $mod_strings;
if (array_key_exists($moduleName . $fieldName, $purified_plcache)) {
return $purified_plcache[$moduleName . $fieldName];
}
$options = array();
$sql = "select * from vtiger_picklist where name=?";
$result = $this->pearDB->pquery($sql, array($fieldName));
$numRows = $this->pearDB->num_rows($result);
if ($numRows == 0) {
$sql = "select * from vtiger_{$fieldName}";
$result = $this->pearDB->pquery($sql, array());
$numRows = $this->pearDB->num_rows($result);
for ($i = 0; $i < $numRows; ++$i) {
$elem = array();
$picklistValue = $this->pearDB->query_result($result, $i, $fieldName);
$picklistValue = decode_html($picklistValue);
$trans_str = $temp_mod_strings[$picklistValue] != '' ? $temp_mod_strings[$picklistValue] : ($app_strings[$picklistValue] != '' ? $app_strings[$picklistValue] : $picklistValue);
while ($trans_str != preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str)) {
$trans_str = preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str);
}
$elem["label"] = $trans_str;
$elem["value"] = $picklistValue;
array_push($options, $elem);
}
} else {
$user = VTWS_PreserveGlobal::getGlobal('current_user');
$details = getPickListValues($fieldName, $user->roleid);
for ($i = 0; $i < sizeof($details); ++$i) {
$elem = array();
$picklistValue = decode_html($details[$i]);
$trans_str = $temp_mod_strings[$picklistValue] != '' ? $temp_mod_strings[$picklistValue] : ($app_strings[$picklistValue] != '' ? $app_strings[$picklistValue] : $picklistValue);
while ($trans_str != preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str)) {
$trans_str = preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str);
}
$elem["label"] = $trans_str;
$elem["value"] = $picklistValue;
array_push($options, $elem);
}
}
$purified_plcache[$moduleName . $fieldName] = $options;
return $options;
}
示例4: deleteImage
function deleteImage()
{
$sql1 = 'SELECT attachmentsid FROM vtiger_salesmanattachmentsrel WHERE smid = ?';
$res1 = $this->db->pquery($sql1, array($this->id));
if ($this->db->num_rows($res1) > 0) {
$attachmentId = $this->db->query_result($res1, 0, 'attachmentsid');
$sql2 = "DELETE FROM vtiger_crmentity WHERE crmid=? AND setype='Users Attachments'";
$this->db->pquery($sql2, array($attachmentId));
$sql3 = 'DELETE FROM vtiger_salesmanattachmentsrel WHERE smid=? AND attachmentsid=?';
$this->db->pquery($sql3, array($this->id, $attachmentId));
$sql2 = "UPDATE vtiger_users SET imagename='' WHERE id=?";
$this->db->pquery($sql2, array($this->id));
$sql4 = 'DELETE FROM vtiger_attachments WHERE attachmentsid=?';
$this->db->pquery($sql4, array($attachmentId));
}
}
示例5: getPickListOptions
function getPickListOptions()
{
$fieldName = $this->getFieldName();
$default_charset = VTWS_PreserveGlobal::getGlobal('default_charset');
$options = array();
$sql = "select * from vtiger_picklist where name=?";
$result = $this->pearDB->pquery($sql, array($fieldName));
$numRows = $this->pearDB->num_rows($result);
if ($numRows == 0) {
$sql = "select * from vtiger_{$fieldName}";
$result = $this->pearDB->pquery($sql, array());
$numRows = $this->pearDB->num_rows($result);
for ($i = 0; $i < $numRows; ++$i) {
$elem = array();
$picklistValue = $this->pearDB->query_result($result, $i, $fieldName);
$picklistValue = decode_html($picklistValue);
$moduleName = getTabModuleName($this->getTabId());
if ($moduleName == 'Events') {
$moduleName = 'Calendar';
}
$elem["label"] = getTranslatedString($picklistValue, $moduleName);
$elem["value"] = $picklistValue;
array_push($options, $elem);
}
} else {
$user = VTWS_PreserveGlobal::getGlobal('current_user');
$details = getPickListValues($fieldName, $user->roleid);
for ($i = 0; $i < sizeof($details); ++$i) {
$elem = array();
$picklistValue = decode_html($details[$i]);
$moduleName = getTabModuleName($this->getTabId());
if ($moduleName == 'Events') {
$moduleName = 'Calendar';
}
$elem["label"] = getTranslatedString($picklistValue, $moduleName);
$elem["value"] = $picklistValue;
array_push($options, $elem);
}
}
return $options;
}
示例6: getReferenceList
public function getReferenceList()
{
static $referenceList = array();
if ($this->referenceList === null) {
if (isset($referenceList[$this->getFieldId()])) {
$this->referenceList = $referenceList[$this->getFieldId()];
return $referenceList[$this->getFieldId()];
}
if (!isset(WebserviceField::$fieldTypeMapping[$this->getUIType()])) {
$this->getFieldTypeFromUIType();
}
$fieldTypeData = WebserviceField::$fieldTypeMapping[$this->getUIType()];
$referenceTypes = array();
if ($this->getUIType() != $this->genericUIType) {
$sql = "select * from vtiger_ws_referencetype where fieldtypeid=?";
$params = array($fieldTypeData['fieldtypeid']);
} else {
$sql = 'select relmodule as type from vtiger_fieldmodulerel where fieldid=?';
$params = array($this->getFieldId());
}
$result = $this->pearDB->pquery($sql, $params);
$numRows = $this->pearDB->num_rows($result);
for ($i = 0; $i < $numRows; ++$i) {
array_push($referenceTypes, $this->pearDB->query_result($result, $i, "type"));
}
//to handle hardcoding done for Calendar module todo activities.
if ($this->tabid == 9 && $this->fieldName == 'parent_id') {
$referenceTypes[] = 'Invoice';
$referenceTypes[] = 'Quotes';
$referenceTypes[] = 'PurchaseOrder';
$referenceTypes[] = 'SalesOrder';
$referenceTypes[] = 'Campaigns';
}
$referenceList[$this->getFieldId()] = $referenceTypes;
$this->referenceList = $referenceTypes;
return $referenceTypes;
}
return $this->referenceList;
}
示例7: migrate
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;
}
示例8: getListViewEntries
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false)
{
require 'user_privileges/user_privileges_' . $this->user->id . '.php';
global $listview_max_textlength, $theme, $default_charset, $current_user, $currentModule;
$fields = $this->queryGenerator->getFields();
$whereFields = $this->queryGenerator->getWhereFields();
$meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule());
$moduleFields = $meta->getModuleFields();
$accessibleFieldList = array_keys($moduleFields);
if ($this->queryGenerator->getReferenceFieldInfoList()) {
$accessibleFieldList = array_merge($this->queryGenerator->getReferenceFieldNameList(), $accessibleFieldList);
}
$listViewFields = array_intersect($fields, $accessibleFieldList);
$referenceFieldList = $this->queryGenerator->getReferenceFieldList();
foreach ($referenceFieldList as $fieldName) {
if (in_array($fieldName, $listViewFields)) {
$field = $moduleFields[$fieldName];
$this->fetchNameList($field, $result);
}
}
$db = PearDatabase::getInstance();
$rowCount = $db->num_rows($result);
$listviewcolumns = $db->getFieldsArray($result);
$ownerFieldList = $this->queryGenerator->getOwnerFieldList();
foreach ($ownerFieldList as $fieldName) {
if (in_array($fieldName, $listViewFields)) {
if (!empty($moduleFields[$fieldName])) {
$field = $moduleFields[$fieldName];
} else {
$field = $this->queryGenerator->getReferenceField($fieldName, false);
if (is_null($field)) {
continue;
}
}
$fldcolname = $field->getColumnName();
$idList = array();
for ($i = 0; $i < $rowCount; $i++) {
$id = $this->db->query_result($result, $i, $fldcolname);
if (!isset($this->ownerNameList[$fieldName][$id])) {
$idList[] = $id;
}
}
if (count($idList) > 0) {
if (!isset($this->ownerNameList[$fieldName]) or !is_array($this->ownerNameList[$fieldName])) {
$this->ownerNameList[$fieldName] = getOwnerNameList($idList);
} else {
$newOwnerList = getOwnerNameList($idList);
$this->ownerNameList[$fieldName] = $this->ownerNameList[$fieldName] + $newOwnerList;
}
}
}
}
foreach ($listViewFields as $fieldName) {
if (!empty($moduleFields[$fieldName])) {
$field = $moduleFields[$fieldName];
} else {
$field = $this->queryGenerator->getReferenceField($fieldName, false);
if (is_null($field)) {
continue;
}
}
if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
$this->setupAccessiblePicklistValueList($fieldName);
}
$idList = array();
if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) {
$modrel = getTabModuleName($field->getTabId());
$fldcolname = 'smowner' . strtolower($modrel);
$j = $rowCount * $k;
$k++;
for ($i = 0; $i < $rowCount; $i++) {
$id = $this->db->query_result($result, $i, $fldcolname);
if (!isset($this->ownerNameListrel[$fieldName][$id])) {
$idList[$j] = $id;
$j++;
}
}
} else {
if (getTabid($currentModule) != $field->getTabId() && $field->getFieldDataType() == 'reference') {
$this->fetchNameList($field, $result, 1);
}
}
if (count($idList) > 0) {
if (!isset($this->ownerNameListrel[$fieldName]) or !is_array($this->ownerNameListrel[$fieldName])) {
$this->ownerNameListrel[$fieldName] = getOwnerNameList($idList);
} else {
$newOwnerList = getOwnerNameList($idList);
$this->ownerNameListrel[$fieldName] = $this->ownerNameListrel[$fieldName] + $newOwnerList;
}
}
}
$useAsterisk = get_use_asterisk($this->user->id);
$data = array();
for ($i = 0; $i < $rowCount; ++$i) {
//Getting the recordId
if ($module != 'Users') {
$baseTable = $meta->getEntityBaseTable();
$moduleTableIndexList = $meta->getEntityTableIndexList();
$baseTableIndex = $moduleTableIndexList[$baseTable];
$recordId = $db->query_result($result, $i, $baseTableIndex);
//.........这里部分代码省略.........
示例9: process
function process()
{
set_time_limit(0);
//ADDED TO AVOID UNEXPECTED TIME OUT WHILE MIGRATING
$returnValue = vtiger_DatabaseMigration::initMigration();
if ($returnValue !== true) {
echo $returnValue;
return false;
}
global $dbconfig;
require dirname(__FILE__) . '/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);
// Why do we do this here? We shouldn't alter here if its not in UTF8.
$query = " ALTER DATABASE " . $dbname . " DEFAULT CHARACTER SET utf8";
$adb->query($query);
$source_directory = $_SESSION['migration_info']['source_directory'];
if (file_exists($source_directory . 'user_privileges/CustomInvoiceNo.php')) {
require_once $source_directory . 'user_privileges/CustomInvoiceNo.php';
}
$versions_non_utf8 = array("50", "501", "502", "503rc2", "503", "504rc");
$php_max_execution_time = 0;
$migrationlog =& LoggerManager::getLogger('MIGRATION');
if (isset($_SESSION['migration_info']['old_version'])) {
$source_version = $_SESSION['migration_info']['old_version'];
}
if (!isset($source_version) || empty($source_version)) {
//If source version is not set then we cannot proceed
echo "<br> Source Version is not set. Please check vtigerversion.php and contiune the Patch Process";
exit;
}
$reach = 0;
include dirname(__FILE__) . "/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%">';
echo "<tr><td colspan='2'><b>Going to apply the Database 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] . " Database changes -- Starts." . $end_tag;
include $filename;
//include the file which contains the corresponding db changes
echo $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " Database changes -- Ends." . $end_tag;
}
}
//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 dirname(__FILE__) . '/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>';
if ($completed == true) {
echo "<script type='text/javascript'>window.parent.Migration_Complete();</script>";
}
create_tab_data_file();
create_parenttab_data_file();
if ($completed == true) {
return true;
}
}