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


PHP DataBase::get方法代码示例

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


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

示例1: find_by_tags

 /**
  * 根据标签查找联系人
  * @param Group_Contact $group_contact
  * @return array
  */
 public function find_by_tags(Group_Contact $group_contact)
 {
     $keys = array();
     $others = array();
     //组织SQL
     foreach ($this->map as $field) {
         $name = (string) $field->name;
         $getprop = (string) $field->accessor;
         if ($getprop) {
             $value = call_user_func(array($group_contact, $getprop));
             if ($value) {
                 if (in_array($name, array('tels', 'emails', 'addresses', 'ims', 'urls', 'relations', 'events'))) {
                     if (in_array($name, array('tels', 'emails', 'ims'))) {
                         $others[$name] = $value;
                     }
                 } else {
                     $keys['gcp_contacts.' . $name] = $value;
                 }
             }
         }
     }
     if (!array_key_exists('gcp_contacts.deleted', $keys)) {
         $keys['gcp_contacts.deleted'] = 0;
     }
     if (!empty($others)) {
         $this->db->select('gcp_contacts.*')->from('gcp_contacts')->where($keys);
         $type = key($others);
         $other = $others[$type];
         $tmp = array();
         foreach ($other as $val) {
             $tmp[] = $val['value'];
         }
         $this->db->join('gcp_' . $type, 'gcp_contacts.gcid = gcp_' . $type . '.gcid', '', 'LEFT')->in('gcp_' . $type . '.value', $tmp);
         $query = $this->db->get();
     } else {
         $query = $this->db->getwhere('gcp_contacts', $keys);
     }
     $result = array();
     if ($query->count()) {
         $rows = $query->result_array(FALSE);
         foreach ($rows as $row) {
             $result[] = $row['gcid'];
         }
     }
     return $result;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:51,代码来源:Group_Contact_Mapper.php

示例2: login

 public static function login($pseudo, $password)
 {
     $password = hash('sha384', $password);
     $user = DataBase::get('users', array(), array('pseudo' => $pseudo, 'password' => $password));
     if (!count($user) || $user === false) {
         $user = DataBase::get('users', array(), array('email' => $pseudo, 'password' => $password));
     }
     if (count($user) && $user !== false) {
         if (!$user[0]['activated']) {
             return false;
         }
         $_SESSION['skyer-user'] = $user[0];
         $_SESSION['skyer-user']['guest'] = false;
         return true;
     } else {
         return false;
     }
 }
开发者ID:KasaiDot,项目名称:SharkDev,代码行数:18,代码来源:user.php

示例3: array

                    $user = DataBase::get('users', array(), array('email' => $_POST['pseudo']));
                }
                if (count($user) && $user !== false) {
                    $user = $user[0];
                    sendMail($user['email'], Config::get('SITE_TITLE'), Config::get('SITE_TITLE'), 'Password reset', 'Dear ' . $user['firstname'] . ' ' . $user['lastname'] . ",<br /><br />Next to your request, your password will be reset. Click the link below to reset it.<br />If you didn't request us to reset your password, simply ignore this mail.<br /><br /><a href=\"http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}?action=reset&token=" . $user['token'] . "\">Reset your password</a><br /><br /><small>Sent from Skyer</small>");
                    $showForgotSubmitted = true;
                } else {
                    die('<h3>User not found</h3>');
                }
            } else {
                $showForgot = true;
            }
            break;
        case 'reset':
            if (isset($_GET['token'])) {
                $user = DataBase::get('users', array(), array('token' => $_GET['token']));
                if (count($user) && $user !== false) {
                    $pass = md5(uniqid(rand(), true));
                    DataBase::update('users', array('password' => hash('sha384', $pass)), array('token' => $_GET['token']));
                    $showReset = true;
                } else {
                    die('<h3>User not found</h3>');
                }
            } else {
                die('<h3>Bad request</h3>');
            }
            break;
    }
}
if (!User::isGuest() && (!isset($_GET['action']) || $_GET['action'] !== 'logout')) {
    header('Location: index.php');
开发者ID:KasaiDot,项目名称:SharkDev,代码行数:31,代码来源:login.php

示例4: array

	                                    <i class="fa fa-envelope"></i> <strong>Read All Messages</strong>
	                                </a>
	                            </div>
	                        </li>
	                    </ul>
	                </li>
	                <li class="dropdown">
	                    <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
	                        <i class="fa fa-bell"></i>  <span class="label label-primary" content="unread-alerts"><?php 
    echo $unreadAlerts;
    ?>
</span>
	                    </a>
	                    <ul class="dropdown-menu dropdown-alerts">
                            <?php 
    $dir = DataBase::get('messages', array('ID', 'recipient', 'sender', 'recipient_dir', 'sender_dir', 'subject', 'sent', 'opened'), array('recipient' => User::getID(), 'recipient_dir' => 'alerts', 'opened' => 0));
    foreach ($dir as $i => $mail) {
        $sender = User::getUserFromID($mail['sender']);
        $mail['sender_ID'] = $mail['sender'];
        $mail['sender'] = $sender['fullname'];
        $recipient = User::getUserFromID($mail['recipient']);
        $mail['recipient_ID'] = $mail['recipient'];
        $mail['recipient'] = $recipient['fullname'];
        ?>
                            <li>
	                            <a href="mailbox.php#/view/<?php 
        echo $mail['ID'];
        ?>
">
	                                <div>
	                                    <i class="fa fa-envelope fa-fw"></i> <?php 
开发者ID:KasaiDot,项目名称:SharkDev,代码行数:31,代码来源:default.php

示例5: getAutogenData

    /**
     * Auto-Generate Data for a specific course.
     * 
     * @global string $urlServer
     * @global string $license
     * @global string $webDir
     * @global string $siteName
     * @global string $Institution
     * @global string $InstitutionUrl
     * @param  int    $courseId
     * @return array
     */
    public static function getAutogenData($courseId) {
        global $urlServer, $license, $webDir, $currentCourseLanguage, $language;
        global $siteName, $Institution, $InstitutionUrl; // NOTICE: DO NOT remove these global vars, include of common.inc, etc, below requires them
        $data = array();
        
        if (empty($currentCourseLanguage)) {
            $plang = $language;
        } else {
            $plang = $currentCourseLanguage;
        }

        $course = Database::get()->querySingle("SELECT * FROM course WHERE id = ?d", intval($courseId));
        if (!$course) {
            return array();
        }
        
        // course language
        $clang = $course->lang;
        $data['course_language'] = $clang;
        $data['course_language_' . $clang] = $GLOBALS['langNameOfLang'][langcode_to_name($clang)];
        // en
        $data['course_language_en'] = ucfirst(langcode_to_name($clang));
        // el
        include("${webDir}/lang/el/common.inc.php");
        include("${webDir}/lang/el/messages.inc.php");
        $data['course_language_el'] = $langNameOfLang[langcode_to_name($clang)]; // do not use GLOBALS here as it will not work
        // revert messages back to current language
        include("${webDir}/lang/" . $plang . "/common.inc.php");
        include("${webDir}/lang/" . $plang . "/messages.inc.php");

        $data['course_url'] = $urlServer . 'courses/' . $course->code;
        $data['course_title_' . $clang] = $course->title;
        $data['course_keywords_' . $clang] = $course->keywords;

        // course license
        if (!empty($course->course_license)) {
            $data['course_license_' . $clang] = $license[$course->course_license]['title'];
            // en
            include("${webDir}/lang/en/common.inc.php");
            include("${webDir}/lang/en/messages.inc.php");
            include("${webDir}/include/license_info.php");
            $data['course_license_en'] = $license[$course->course_license]['title'];
            //el
            include("${webDir}/lang/el/common.inc.php");
            include("${webDir}/lang/el/messages.inc.php");
            include("${webDir}/include/license_info.php");
            $data['course_license_el'] = $license[$course->course_license]['title'];
            // revert messages back to current language
            include("${webDir}/lang/" . $clang . "/common.inc.php");
            include("${webDir}/lang/" . $clang . "/messages.inc.php");
            include("${webDir}/include/license_info.php");
        } else {
            $data['course_license_' . $clang] = '';
            if ($clang != 'en') {
                $data['course_license_en'] = '';
            }
            if ($clang != 'el') {
                $data['course_license_el'] = '';
            }
        }

        // first creation date
        $ts = strtotime($course->created);
        if ($ts > 0) {
            $data['course_firstCreateDate'] = date("Y-m-d\TH:i:sP", $ts);
        }

        // course review data
        $review = Database::get()->querySingle("SELECT * FROM course_review WHERE course_id = ?d", intval($courseId));
        if ($review) {
            $ts = strtotime($review->last_review);
            if ($ts > 0) {
                $data['course_lastLevelConfirmation'] = date("Y-m-d\TH:i:sP", $ts);
            }
            $level = intval($review->level);
            if ($level >= self::A_MINUS_LEVEL) {
                $data['course_confirmAMinusLevel'] = 'true';
            }
            if ($level >= self::A_LEVEL) {
                $data['course_confirmALevel'] = 'true';
            }
            if ($level >= self::A_PLUS_LEVEL) {
                $data['course_confirmAPlusLevel'] = 'true';
            }
        }

        // course description types
        $desctypes = array(
//.........这里部分代码省略.........
开发者ID:nikosv,项目名称:openeclass,代码行数:101,代码来源:CourseXML.php

示例6: die

            die('<h3>That\'s not your mail !</h3>');
        }
        die('true');
        break;
    case 'unread':
        $unread = DataBase::query('SELECT COUNT(*) FROM messages WHERE opened = 0 AND recipient_dir = ' . DataBase::_secure($_GET['folder']) . ' AND recipient = ' . User::getID())->fetch()[0];
        if (strval($unread)) {
            die($unread);
        } else {
            die;
        }
        break;
    case 'send':
        // check message HTML does not comport malicious tags
        // for example with HTMLPurify PHP library
        $recipient = DataBase::get('users', array('ID'), array('fullname' => $_POST['recipient']));
        if (!count($recipient) || $recipient === false) {
            die('false');
        }
        if (DataBase::insert('messages', array('sender' => User::getID(), 'recipient' => $recipient[0]['ID'], 'subject' => htmlspecialchars($_POST['subject']), 'content' => $_POST['content'], 'sent' => array('NOW()'), 'opened' => 0, 'answerTo' => 0, 'sender_dir' => 'sent', 'recipient_dir' => 'inbox'))) {
            if (DataBase::insert('messages', array('sender' => User::getID(), 'recipient' => $recipient[0]['ID'], 'subject' => htmlspecialchars($_POST['subject']), 'content' => $_POST['content'], 'sent' => array('NOW()'), 'opened' => 0, 'answerTo' => 0, 'sender_dir' => 'sent', 'recipient_dir' => 'sent'))) {
            }
            die('true');
        } else {
            die('false');
        }
        break;
    default:
        die('<h3>Unknwon action</h3>');
        break;
}
开发者ID:KasaiDot,项目名称:SharkDev,代码行数:31,代码来源:mailbox-i.php

示例7: elseif

 } elseif (strlen($_POST['password']) < 6) {
     $err = 'Password must be at least 6 characters';
 } elseif (strlen($_POST['password']) > 60) {
     $err = 'Password must be shorter than 60 characters';
 } elseif ($_POST['password'] !== $_POST['password-confirm']) {
     $err = 'The two passwords does not match';
 } elseif ($_POST['email'] !== $_POST['email-confirm']) {
     $err = 'The two email does not match';
 } elseif (!isset($_POST['agree-terms']) || !$_POST['agree-terms']) {
     $err = 'You must agree terms and privacy';
 } else {
     $user = DataBase::get('users', array(), array('pseudo' => $_POST['pseudo']));
     if (count($user) && $user !== false) {
         $err = 'This pseudo is already used !';
     } else {
         $user = DataBase::get('users', array(), array('email' => $_POST['email']));
         if (count($user) && $user !== false) {
             $err = 'This email is already used !';
         } else {
             $token = md5(uniqid(rand(), true)) . md5(uniqid(rand(), true));
             if (DataBase::insert('users', array('pseudo' => $_POST['pseudo'], 'password' => hash('sha384', $_POST['password']), 'email' => $_POST['email'], 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'fullname' => $_POST['firstname'] . ' ' . $_POST['lastname'], 'activated' => 0, 'rights' => 1, 'register' => 'NOW()', 'reputation' => 0, 'token' => $token))) {
                 try {
                     chdir(__DIR__ . '/server/users');
                     Lib::recurseCopy('.model', $_POST['pseudo']);
                     sendMail($_POST['email'], Config::get('SITE_TITLE'), Config::get('SITE_EMAIL'), 'Activate your account', 'Dear ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . ",<br /><br />You've just created an account. To activate it, use the link below.<br /><br /><a href=\"http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}?activate=" . $token . "\">Activate your account</a><br /><br /><small>Sent from Skyer</small>");
                     $registered = true;
                 } catch (Exception $e) {
                     $err = 'Internal disk error. Please try again.';
                 }
             } else {
                 $err = 'DataBase error. Please try again.';
开发者ID:KasaiDot,项目名称:SharkDev,代码行数:31,代码来源:register.php


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