HasRecords() public method

Determines if a query contains any rows
public HasRecords ( string $sql = "" ) : boolean
$sql string [Optional] If specified, the query is first executed Otherwise, the last query is used for comparison
return boolean TRUE if records exist, FALSE if not or query error
コード例 #1
0
/** Đăng nhập admin cp */
function admin_cp_login()
{
    global $hmuser;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('admin_cp_login');
    $user_login = hm_post('login');
    $password = hm_post('password');
    $logmein = hm_post('log-me-in');
    if (is_numeric($logmein)) {
        $tableName = DB_PREFIX . "users";
        $whereArray = array('user_login' => MySQL::SQLValue($user_login));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            $row = $hmdb->Row();
            $salt = $row->salt;
            $user_pass = $row->user_pass;
            $password_encode = hm_encode_str(md5($password . $salt));
            if ($password_encode == $user_pass) {
                $time = time();
                $ip = hm_ip();
                $cookie_array = array('time' => $time, 'ip' => $ip, 'user_login' => $user_login, 'admincp' => 'yes');
                $cookie_user = hm_encode_str($cookie_array);
                setcookie('admin_login', $cookie_user, time() + COOKIE_EXPIRES, '/');
                $_SESSION['admin_login'] = $cookie_user;
                return json_encode(array('status' => 'success', 'mes' => _('Đăng nhập thành công')));
            } else {
                return json_encode(array('status' => 'error', 'mes' => _('Sai mật khẩu')));
            }
        } else {
            return json_encode(array('status' => 'error', 'mes' => _('Không có tài khoản này')));
        }
    }
}
コード例 #2
0
        return FALSE;
    }
}
function get_uri_data($args)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    if (!is_array($args)) {
        parse_str($args, $args);
    }
    if (isset($args['uri'])) {
        $uri = $args['uri'];
    } else {
        $uri = FALSE;
    }
    if (isset($args['id'])) {
        $id_uri = $args['id'];
    } else {
        $id_uri = FALSE;
    }
    $tableName = DB_PREFIX . "request_uri";
    if (is_numeric($id_uri)) {
        $whereArray = array('id' => MySQL::SQLValue($id_uri));
    } else {
        $whereArray = array('uri' => MySQL::SQLValue($uri));
    }
    $hmdb->SelectRows($tableName, $whereArray);
    if ($hmdb->HasRecords()) {
        $row = $hmdb->Row();
        return $row;
    } else {
コード例 #3
0
function list_plugin($active = 1)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    $tableName = DB_PREFIX . "plugin";
    $whereArray = array('active' => MySQL::SQLValue($active, MySQL::SQLVALUE_NUMBER));
    $hmdb->SelectRows($tableName, $whereArray);
    if ($hmdb->HasRecords()) {
        while ($row = $hmdb->Row()) {
            $return[] = $row->key;
        }
        return json_encode($return);
    } else {
        return array();
    }
}
コード例 #4
0
function is_theme_active($theme)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    if (is_dir(BASEPATH . HM_THEME_DIR . '/' . $theme) and is_file(BASEPATH . HM_THEME_DIR . '/' . $theme . '/init.php')) {
        $tableName = DB_PREFIX . "option";
        $whereArray = array('section' => MySQL::SQLValue('system_setting'), 'key' => MySQL::SQLValue('theme'), 'value' => MySQL::SQLValue($theme));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
コード例 #5
0
/** Kiểm tra mã đổi mật khẩu tồn tại */
function newpw_checkkey()
{
    global $hmuser;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('newpw_checkkey');
    $key = hm_get('key');
    $tableName = DB_PREFIX . "field";
    $whereArray = array('name' => MySQL::SQLValue('lostpw_key'), 'object_type' => MySQL::SQLValue('user'), 'val' => MySQL::SQLValue($key));
    $hmdb->SelectRows($tableName, $whereArray);
    if ($hmdb->HasRecords()) {
        return TRUE;
    } else {
        hm_exit(_('Đường link đã hết hạn'));
    }
}
コード例 #6
0
/** bảng danh sách thành viên */
function user_show_data($user_group, $perpage)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('user_show_data');
    $request_paged = hm_get('paged', 1);
    $paged = $request_paged - 1;
    $offset = $paged * $perpage;
    $limit = "LIMIT {$perpage} OFFSET {$offset}";
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ORDER BY id DESC {$limit}")) {
        $hmdb->Kill();
    }
    if ($hmdb->HasRecords()) {
        /* Trả về các user */
        while ($row = $hmdb->Row()) {
            $array_use[] = array('id' => $row->id, 'user_nicename' => $row->user_nicename, 'user_role' => user_role_id_to_nicename($row->user_role));
        }
        $array['user'] = $array_use;
        /* Tạo pagination */
        $hmdb->Query(" SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ");
        $total_item = $hmdb->RowCount();
        $total_page = ceil($total_item / $perpage);
        $first = '1';
        if ($request_paged > 1) {
            $previous = $request_paged - 1;
        } else {
            $previous = $first;
        }
        if ($request_paged < $total_page) {
            $next = $request_paged + 1;
        } else {
            $next = $total_page;
        }
        $array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged);
    } else {
        $array['user'] = array();
        $array['pagination'] = array();
    }
    return hook_filter('user_show_data', json_encode($array, TRUE));
}
コード例 #7
0
function content_show_data($key, $status, $perpage)
{
    global $hmcontent;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('content_show_data');
    $request_paged = hm_get('paged', 1);
    $paged = $request_paged - 1;
    $offset = $paged * $perpage;
    $limit = "LIMIT {$perpage} OFFSET {$offset}";
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "content WHERE `key` = '{$key}' AND status = '{$status}' ORDER BY id DESC {$limit}")) {
        $hmdb->Kill();
    }
    if ($hmdb->HasRecords()) {
        /* Trả về các content */
        while ($row = $hmdb->Row()) {
            $array_con[] = array('id' => $row->id, 'name' => $row->name, 'slug' => $row->slug);
        }
        $array['content'] = $array_con;
        /* Tạo pagination */
        $hmdb->Query(" SELECT * FROM " . DB_PREFIX . "content WHERE `key` = '{$key}' AND status = '{$status}' ");
        $total_item = $hmdb->RowCount();
        $total_page = ceil($total_item / $perpage);
        $first = '1';
        if ($request_paged > 1) {
            $previous = $request_paged - 1;
        } else {
            $previous = $first;
        }
        if ($request_paged < $total_page) {
            $next = $request_paged + 1;
        } else {
            $next = $total_page;
        }
        $array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged);
        $all_content = $hmcontent->hmcontent;
        if (isset($all_content[$key]['chapter']) and $all_content[$key]['chapter'] == TRUE) {
            $array['chapter'] = TRUE;
        } else {
            $array['chapter'] = FALSE;
        }
    } else {
        $array['content'] = array();
        $array['pagination'] = array();
        $array['chapter'] = FALSE;
    }
    return hook_filter('content_show_data', json_encode($array, TRUE));
}
コード例 #8
0
function taxonomy_checkbox_list($args = array())
{
    hook_action('taxonomy_checkbox_list');
    hook_filter('taxonomy_checkbox_list_before', $args);
    global $hmtaxonomy;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    @($key = $args['key']);
    @($parent = $args['parent'] ? $args['parent'] : 0);
    @($default_value = $args['default_value']);
    @($object_id = $args['object_id']);
    if (is_numeric($object_id)) {
        $tableName = DB_PREFIX . "relationship";
        $whereArray = array('object_id' => MySQL::SQLValue($object_id), 'relationship' => MySQL::SQLValue('contax'));
        $hmdb->SelectRows($tableName, $whereArray);
        while ($row = $hmdb->Row()) {
            $default_value[] = $row->target_id;
        }
    }
    if (!is_array($default_value)) {
        $default_value = array();
    }
    $tax = $hmtaxonomy->hmtaxonomy;
    if (isset($tax[$key])) {
        $tableName = DB_PREFIX . "taxonomy";
        $whereArray = array('key' => MySQL::SQLValue($key), 'parent' => MySQL::SQLValue($parent), 'status' => MySQL::SQLValue('public'));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            if ($parent != 0) {
                echo '<ul class="taxonomy_tree_sub_group taxonomy_tree_sub_group_of_' . $parent . '">';
            }
            while ($row = $hmdb->Row()) {
                $taxs[] = $row;
            }
            foreach ($taxs as $tax) {
                if (in_array($tax->id, $default_value)) {
                    $checked = 'checked';
                } else {
                    $checked = '';
                }
                echo '<li data-id="' . $tax->id . '" data-slug="' . $tax->slug . '" class="tax_tree_item tax_tree_item_' . $tax->id . '">';
                echo '<input type="checkbox" name="taxonomy[]" value="' . $tax->id . '" ' . $checked . ' /> ';
                echo '<label>' . $tax->name . '</label>';
                taxonomy_checkbox_list(array('key' => $key, 'parent' => $tax->id, 'default_value' => $default_value));
                echo '</li>';
            }
            if ($parent != 0) {
                echo '</ul>';
            }
        }
    }
}
コード例 #9
0
/** Ajax xóa thư mục */
function del_media_group($args)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    $id = $args['group_id'];
    if (is_numeric($id)) {
        /** Xóa thư mục */
        $path = BASEPATH . '/' . HM_CONTENT_DIR . '/uploads/' . get_media_group_part($id);
        DeleteDir($path);
        $tableName = DB_PREFIX . "media_groups";
        $whereArray = array('id' => MySQL::SQLValue($id));
        $hmdb->DeleteRows($tableName, $whereArray);
        /** Xóa các file trong thư mục */
        $tableName = DB_PREFIX . "media";
        $whereArray = array('media_group_id' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            while ($row = $hmdb->Row()) {
                $id_media_file = $row->id;
                delete_media($id_media_file);
            }
        }
        /** Xóa thư mục con */
        $tableName = DB_PREFIX . "media_groups";
        $whereArray = array('parent' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            while ($row = $hmdb->Row()) {
                $id_sub_folder = $row->id;
                del_media_group(array('group_id' => $id_sub_folder));
            }
        }
    }
}