当前位置: 首页>>代码示例>>PHP>>正文


PHP PearDatabase::query方法代码示例

本文整理汇总了PHP中PearDatabase::query方法的典型用法代码示例。如果您正苦于以下问题:PHP PearDatabase::query方法的具体用法?PHP PearDatabase::query怎么用?PHP PearDatabase::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PearDatabase的用法示例。


在下文中一共展示了PearDatabase::query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unset

 /** 
  * Load a user based on the user_name in $this, ignoring the damned password
  * @return -- this if load was successul and null if load failed.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
  * All Rights Reserved..
  * Contributor(s): Gregory Wolgemuth___________________________..
  */
 function remote_load_user()
 {
     $usr_name = $this->column_fields["user_name"];
     /*You can't "attempt" to login when we're using remote auth - nuts to it
       if(isset($_SESSION['loginattempts'])){
               $_SESSION['loginattempts'] += 1;
       }else{
               $_SESSION['loginattempts'] = 1; 
       }
       if($_SESSION['loginattempts'] > 5){
               $this->log->warn("SECURITY: " . $usr_name . " has attempted to login ".         $_SESSION['loginattempts'] . " times.");
       }*/
     $this->log->debug("Starting remote user load for {$usr_name}");
     $validation = 0;
     unset($_SESSION['validation']);
     if (!isset($this->column_fields["user_name"]) || $this->column_fields["user_name"] == "") {
         return null;
     }
     //I have no idea what these do, or if they're even necessary. There's a lot of salted MD5 hashing and base64 encoding going on, but I just don't know why
     if ($this->validation_check('aW5jbHVkZS9pbWFnZXMvc3VnYXJzYWxlc19tZC5naWY=', '1a44d4ab8f2d6e15e0ff6ac1c2c87e6f', '866bba5ae0a15180e8613d33b0acc6bd') == -1) {
         $validation = -1;
     }
     if ($this->validation_check('aW5jbHVkZS9pbWFnZXMvcG93ZXJlZF9ieV9zdWdhcmNybS5naWY=', '3d49c9768de467925daabf242fe93cce') == -1) {
         $validation = -1;
     }
     if ($this->authorization_check('aW5kZXgucGhw', 'PEEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nIHRhcmdldD0nX2JsYW5rJz48aW1nIGJvcmRlcj0nMCcgc3JjPSdpbmNsdWRlL2ltYWdlcy9wb3dlcmVkX2J5X3N1Z2FyY3JtLmdpZicgYWx0PSdQb3dlcmVkIEJ5IFN1Z2FyQ1JNJz48L2E+', 1) == -1) {
         $validation = -1;
     }
     /*More checking the password - we still don't care!
                    $authCheck = false;
                    $authCheck = $this->doLogin($user_password);
     
                    if(!$authCheck)
                    {
                            $this->log->warn("User authentication for $usr_name failed");
                            return null;
                    }
                    */
     $this->log->debug("Checking to see if user exists in DB");
     //When in Rome, don't parameterize your database queries
     $count_query = "SELECT COUNT(*) AS count FROM {$this->table_name} WHERE user_name='{$usr_name}'";
     $result = $this->db->requireSingleResult($count_query, false);
     $row = $this->db->fetchByAssoc($result);
     $numUsers = $row['count'];
     //User is not in the database. Perform LDAP lookup of the user, retrieve pertinent info, stuff into database
     //Also, if user is first user in the system, assign admin role of some kind, or something, I dunno
     if ($numUsers == 0) {
         $this->log->debug("User does not exist in DB, starting to perform LDAP lookup");
         /*List of things we should look up and set somehow
                                is_admin - Set to "on" for the first user. Damnitall, a boolean value that's "on" or "off"?
                                first_name - Given name
                                last_name - Surname
                                status - Should be hardcoded to "Active"
                                email1 - User's primary e-mail, we can look this one up properly in LDAP
         
                                TODO: Does the user need to have a default role set?
                                */
         $total_count_query = "SELECT COUNT(*) AS count FROM {$this->table_name}";
         $result = $this->db->requireSingleResult($total_count_query, false);
         $row = $this->db->fetchByAssoc($result);
         $totalNumUsers = $row['count'];
         $roleid_query = "SELECT roleid FROM vtiger_role ORDER BY roleid DESC";
         $result = $this->db->query($roleid_query);
         $row = $this->db->fetchByAssoc($result);
         $user_roleid = $row['roleid'];
         $this->log->debug("Chosen roleid is {$user_roleid}");
         $this->log->debug("Total number of users in vtiger table {$this->table_name} appears to be {$totalNumUsers}");
         global $ldap_host;
         global $ldap_base;
         global $ldap_bind_dn;
         global $ldap_bind_pw;
         $this->log->debug("LDAP settings appear to be {$ldap_bind_dn} on {$ldap_host} and base {$ldap_base}");
         $this->log->debug("Trying a manual LDAP bind");
         $lconn = ldap_connect($ldap_host);
         $this->log->debug(ldap_error($lconn));
         ldap_set_option($lconn, LDAP_OPT_PROTOCOL_VERSION, 3);
         $lbind = ldap_bind($lconn, $ldap_bind_dn, $ldap_bind_pw);
         if (!$lbind) {
             $this->log->debug("Something screwed up on the LDAP bind, damnitall");
         }
         $user_dn = "uid={$usr_name},{$ldap_base}";
         $this->log->debug("LDAP DN set to {$user_dn}");
         /*WARNING WARNING WARNING
           PHP's LDAP functions DO NOT conform to the LDAP RFCs
           Please consult PHP's manual to find out what this code is doing
           Because it isn't doing what you expect*/
         $ldap_read_result = ldap_read($lconn, $user_dn, "objectClass=*", array("givenName", "sn", "mail", "eseriMailAlternateAddress"));
         if ($ldap_read_result) {
             $this->log->debug("LDAP result set returned successfully");
             $ldap_arr = ldap_get_entries($lconn, $ldap_read_result);
             //PHP is ****ing stupid and forces lowercase on returned attribute names
             //READ RFCs WHEN YOU IMPLEMENT OR WOOGDOR SMASH
             $this->column_fields['first_name'] = $ldap_arr[0]['givenname'][0];
//.........这里部分代码省略.........
开发者ID:CirrusComputing,项目名称:EnterpriseLibre,代码行数:101,代码来源:Users.php

示例2: 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'>&nbsp;</td></tr>";
         $start_tag = "<tr><td colspan='2'><b><font color='red'>&nbsp;";
         $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;
 }
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:84,代码来源:utils.php

示例3: 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'>&nbsp;</td></tr>";
         $start_tag = "<tr><td colspan='2'><b><font color='red'>&nbsp;";
         $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;
     }
 }
开发者ID:vtiger-jp,项目名称:vtigercrm-5.1.x-ja,代码行数:86,代码来源:migrate.php


注:本文中的PearDatabase::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。