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


PHP SelectQuery::fetchAssoc方法代码示例

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


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

示例1: action_create

    public function action_create()
    {
        if (is_post()) {
            $parameters = get_previous_parameters();
            $object = new CommentObj();
            $object = $object->fromRequest();
            $object['foreign_id'] = empty($object['foreign_id']) ? reset($parameters) : $object['foreign_id'];
            $object['foreign_table'] = empty($object['foreign_table']) ? table_name(get_previous_area()) : $object['foreign_table'];
            //If we don't have a logged in user, create a dummy account
            if (!BackendUser::check()) {
                $query = new SelectQuery('BackendUser');
                $query->filter('`email` = :email');
                if ($old_user = Controller::getVar('user')) {
                    $existing_user = $query->fetchAssoc(array(':email' => $old_user['email']));
                }
                switch (true) {
                    case $existing_user && $existing_user['confirmed'] && $existing_user['active']:
                        //Attribute quote to user? Seems risque, actually, if I know a user's email address, I can just attribute to him. Auth first
                        Backend::addError('Comment not added. Please login first');
                        return false;
                        break;
                    case $existing_user && !$existing_user['confirmed'] && $existing_user['active']:
                        //Unregistered user commented before
                        $object['user_id'] = $existing_user['id'];
                        break;
                    default:
                    case !$existing_user:
                        $user_data = array('name' => $old_user['name'], 'surname' => '', 'email' => $old_user['email'], 'website' => $old_user['website'], 'username' => $old_user['email'], 'password' => get_random(), 'confirmed' => 0, 'active' => 1);
                        $user = self::getObject('BackendUser');
                        if ($user->create($user_data)) {
                            $object['user_id'] = $user->array['id'];
                            $url = SITE_LINK . '/?q=backend_user/confirm/' . $user->array['salt'];
                            $app_name = ConfigValue::get('Title');
                            $message = <<<END
Hi {$user->array['name']}!

Thank you for your comment on {$app_name}. An account has automatically been created for you. To activate it, please click on the following link:

{$url}

Please note that you don't need to do this for your comments to show, but this account will be deleted if it isn't confirmed in a weeks time.

Regards
END;
                            send_email($user->array['email'], 'Thank you for your comment.', $message);
                        } else {
                            Backend::addError('Could not create user to add Comment');
                            return false;
                        }
                        break;
                }
            }
            $object = array_filter($object, create_function('$var', 'return !is_null($var);'));
            Controller::setVar('obj', $object);
        }
        return parent::action_create();
    }
开发者ID:jrgns,项目名称:backend-php,代码行数:57,代码来源:Comment.obj.php

示例2: check

 /**
  * Check if a tag exists for a specified Area, add it if it doesn't
  */
 public static function check($name, $area)
 {
     if ($area instanceof DBObject) {
         $area = $area->getMeta('table');
     }
     //Check if tag exists
     $query = new SelectQuery('Tag');
     $query->filter('`foreign_table` = :table')->filter('`name` = :tag');
     if ($tag = $query->fetchAssoc(array(':tag' => $name, ':table' => $area))) {
         return $tag;
     }
     //Tag doesn't already exist
     $data = array('name' => $name, 'foreign_table' => $area, 'active' => 1);
     $tag = new TagObj();
     if ($tag->create($data)) {
         return $tag->array;
     }
     return false;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:22,代码来源:Tag.obj.php

示例3: hook_init

 /**
  * We check if there's any content of the name ?q=:name
  */
 public static function hook_init()
 {
     $query = Controller::getVar('q');
     if (empty($query)) {
         return;
     }
     if (substr($query, -1) == '/') {
         $query = substr($query, 0, strlen($query) - 1);
     }
     $select = new SelectQuery('Content');
     $select->filter('`name` = :query');
     $row = $select->fetchAssoc(array(':query' => $query));
     if ($row) {
         Controller::setVar('q', 'content/' . $row['id']);
     }
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:19,代码来源:Content.obj.php

示例4: userStats

    public static function userStats()
    {
        $msg = array();
        $query = new SelectQuery('BackendUser');
        $query->field('COUNT(*) AS `Total`, SUM(IF(TO_DAYS(NOW()) - TO_DAYS(`added`) < 7, 1, 0)) AS `New`')->filter('`active` = 1')->filter('`confirmed` = 1');
        if ($stats = $query->fetchAssoc()) {
            $msg[] = 'There are a total of ' . $stats['Total'] . ' **active** users,
of which ' . $stats['New'] . ' signed up in the last 7 days';
        }
        $query = new SelectQuery('BackendUser');
        $query->field('COUNT(*) AS `Total`, SUM(IF(TO_DAYS(NOW()) - TO_DAYS(`added`) < 7, 1, 0)) AS `New`')->filter('`active` = 1')->filter('`confirmed` = 1');
        if ($stats = $query->fetchAssoc()) {
            $msg[] = 'There are a total of ' . $stats['Total'] . ' **unconfirmed** users,
of which ' . $stats['New'] . ' signed up in the last 7 days';
        }
        $msg = implode(PHP_EOL . PHP_EOL, $msg);
        send_email(ConfigValue::get('author.Email', ConfigValue::get('application.Email', 'info@' . SITE_DOMAIN)), 'User stats for ' . Backend::get('Title'), $msg);
        return true;
    }
开发者ID:jrgns,项目名称:backend-php,代码行数:19,代码来源:BackendUser.obj.php


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