无法从查询执行中获得准确的结果

时间:2019-05-29 07:15:18

标签: mongodb codeigniter

我正在将CodeIgniterMongoDB一起使用,并希望使用ID来获取数据,该ID保存在MongoDB中,我执行了打印数据的查询,但是我不知道要打印什么数据

我执行此查询

$query=$this->mongo_db->where('posts', array('_id' => new \MongoDB\BSON\ObjectID($id)));

并获得此结果没有任何数据

Mongo_db Object
(
  [CodeIgniter:Mongo_db:private] => User Object
    (
        [benchmark] => CI_Benchmark Object
            (
                [marker] => Array
                    (
                        [total_execution_time_start] => 1559113613.9923
                        [loading_time:_base_classes_start] => 1559113613.9923
                        [loading_time:_base_classes_end] => 1559113614.0023
                        [controller_execution_time_( User / single )_start] => 1559113614.0023
                    )

            )

        [hooks] => CI_Hooks Object
            (
                [enabled] => 
                [hooks] => Array
                    (
                    )

                [_objects:protected] => Array
                    (
                    )

                [_in_progress:protected] => 
            )

        [config] => CI_Config Object
            (
                [config] => Array
                    (
                        [base_url] => http://localhost/chronicle/
                        [index_page] => index.php
                        [uri_protocol] => REQUEST_URI
                        [url_suffix] => 
                        [language] => english
                        [charset] => UTF-8
                        [enable_hooks] => 
                        [subclass_prefix] => MY_
                        [composer_autoload] => 
                        [permitted_uri_chars] => a-z 0-9~%.:_\-
                        [enable_query_strings] => 
                        [controller_trigger] => c
                        [function_trigger] => m
                        [directory_trigger] => d
                        [allow_get_array] => 1
                        [log_threshold] => 0
                        [log_path] => 
                        [log_file_extension] => 
                        [log_file_permissions] => 420
                        [log_date_format] => Y-m-d H:i:s
                        [error_views_path] => 
                        [cache_path] => 
                        [cache_query_string] => 
                        [encryption_key] => 
                        [sess_driver] => files
                        [sess_cookie_name] => ci_session
                        [sess_expiration] => 7200
                        [sess_save_path] => 
                        [sess_match_ip] => 
                        [sess_time_to_update] => 300
                        [sess_regenerate_destroy] => 
                        [cookie_prefix] => 
                        [cookie_domain] => 
                        [cookie_path] => /
                        [cookie_secure] => 
                        [cookie_httponly] => 
                        [standardize_newlines] => 
                        [global_xss_filtering] => 
                        [csrf_protection] => 
                        [csrf_token_name] => csrf_test_name
                        [csrf_cookie_name] => csrf_cookie_name
                        [csrf_expire] => 7200
                        [csrf_regenerate] => 1
                        [csrf_exclude_uris] => Array
                            (
                            )

                        [compress_output] => 
                        [time_reference] => local
                        [rewrite_short_tags] => 
                        [proxy_ips] => 
                        [mongo_db] => Array
                            (
                                [active_config_group] => default
                                [default] => Array
                                    (
                                        [settings] => Array
                                            (
                                                [auth] => 1
                                                [debug] => 1
                                                [return_as] => array
                                                [auto_reset_query] => 1
                                            )

                                        [connection_string] => 
                                        [connection] => Array
                                            (
                                                [host] => 127.0.0.1
                                                [port] => 27017
                                                [user_name] => admin
                                                [user_password] => admin
                                                [db_name] => centralchronicle
                                                [db_options] => Array
                                                    (
                                                    )

                                            )

                                        [driver] => Array
                                            (
                                            )

                                    )

                            )

                    )

                [is_loaded] => Array
                    (
                        [0] => D:\xampp\htdocs\chronicle\application\config/mongo_db.php
                    )

                [_config_paths] => Array
                    (
                        [0] => D:\xampp\htdocs\chronicle\application\
                    )

            )

        [log] => CI_Log Object
            (
                [_log_path:protected] => D:\xampp\htdocs\chronicle\application\logs/
                [_file_permissions:protected] => 420
                [_threshold:protected] => 0
                [_threshold_array:protected] => Array
                    (
                    )

                [_date_fmt:protected] => Y-m-d H:i:s
                [_file_ext:protected] => php
                [_enabled:protected] => 1
                [_levels:protected] => Array
                    (
                        [ERROR] => 1
                        [DEBUG] => 2
                        [INFO] => 3
                        [ALL] => 4
                    )

            )

        [utf8] => CI_Utf8 Object
            (
            )

        [uri] => CI_URI Object
            (
                [keyval] => Array
                    (
                    )

                [uri_string] => User/single/5ced0e57ed4e3e0fbc017e19
                [segments] => Array
                    (
                        [1] => User
                        [2] => single
                        [3] => 5ced0e57ed4e3e0fbc017e19
                    )

                [rsegments] => Array
                    (
                        [1] => User
                        [2] => single
                        [3] => 5ced0e57ed4e3e0fbc017e19
                    )

                [_permitted_uri_chars:protected] => a-z 0-9~%.:_\-
                [config] => CI_Config Object
                    (
                        [config] => Array
                            (
                                [base_url] => http://localhost/chronicle/
                                [index_page] => index.php
                                [uri_protocol] => REQUEST_URI
                                [url_suffix] => 
                                [language] => english
                                [charset] => UTF-8
                                [enable_hooks] => 
                                [subclass_prefix] => MY_
                                [composer_autoload] => 
                                [permitted_uri_chars] => a-z 0-9~%.:_\-
                                [enable_query_strings] => 
                                [controller_trigger] => c
                                [function_trigger] => m
                                [directory_trigger] => d
                                [allow_get_array] => 1
                                [log_threshold] => 0
                                [log_path] => 
                                [log_file_extension] => 
                                [log_file_permissions] => 420
                                [log_date_format] => Y-m-d H:i:s
                                [error_views_path] => 
                                [cache_path] => 
                                [cache_query_string] => 
                                [encryption_key] => 
                                [sess_driver] => files
                                [sess_cookie_name] => ci_session
                                [sess_expiration] => 7200
                                [sess_save_path] => 
                                [sess_match_ip] => 
                                [sess_time_to_update] => 300
                                [sess_regenerate_destroy] => 
                                [cookie_prefix] => 
                                [cookie_domain] => 
                                [cookie_path] => /
                                [cookie_secure] => 
                                [cookie_httponly] => 
                                [standardize_newlines] => 
                                [global_xss_filtering] => 
                                [csrf_protection] => 
                                [csrf_token_name] => csrf_test_name
                                [csrf_cookie_name] => csrf_cookie_name
                                [csrf_expire] => 7200
                                [csrf_regenerate] => 1
                                [csrf_exclude_uris] => Array
                                    (
                                    )

                                [compress_output] => 
                                [time_reference] => local
                                [rewrite_short_tags] => 
                                [proxy_ips] => 
                                [mongo_db] => Array
                                    (
                                        [active_config_group] => default
                                        [default] => Array
                                            (
                                                [settings] => Array
                                                    (
                                                        [auth] => 1
                                                        [debug] => 1
                                                        [return_as] => array
                                                        [auto_reset_query] => 1
                                                    )

                                                [connection_string] => 
                                                [connection] => Array
                                                    (
                                                        [host] => 127.0.0.1
                                                        [port] => 27017
                                                        [user_name] => admin
                                                        [user_password] => admin
                                                        [db_name] => centralchronicle
                                                        [db_options] => Array
                                                            (
                                                            )

                                                    )

                                                [driver] => Array
                                                    (
                                                    )

                                            )

                                    )

                            )

                        [is_loaded] => Array
                            (
                                [0] => D:\xampp\htdocs\chronicle\application\config/mongo_db.php
                            )

                        [_config_paths] => Array
                            (
                                [0] => D:\xampp\htdocs\chronicle\application\
                            )

                    )

            )

        [router] => CI_Router Object
            (
                [config] => CI_Config Object
                    (
                        [config] => Array
                            (
                                [base_url] => http://localhost/chronicle/
                                [index_page] => index.php
                                [uri_protocol] => REQUEST_URI
                                [url_suffix] => 
                                [language] => english
                                [charset] => UTF-8
                                [enable_hooks] => 
                                [subclass_prefix] => MY_
                                [composer_autoload] => 
                                [permitted_uri_chars] => a-z 0-9~%.:_\-
                                [enable_query_strings] => 
                                [controller_trigger] => c
                                [function_trigger] => m
                                [directory_trigger] => d
                                [allow_get_array] => 1
                                [log_threshold] => 0
                                [log_path] => 
                                [log_file_extension] => 
                                [log_file_permissions] => 420
                                [log_date_format] => Y-m-d H:i:s
                                [error_views_path] => 
                                [cache_path] => 
                                [cache_query_string] => 
                                [encryption_key] => 
                                [sess_driver] => files
                                [sess_cookie_name] => ci_session
                                [sess_expiration] => 7200
                                [sess_save_path] => 
                                [sess_match_ip] => 
                                [sess_time_to_update] => 300
                                [sess_regenerate_destroy] => 
                                [cookie_prefix] => 
                                [cookie_domain] => 
                                [cookie_path] => /
                                [cookie_secure] => 
                                [cookie_httponly] => 
                                [standardize_newlines] => 
                                [global_xss_filtering] => 
                                [csrf_protection] => 
                                [csrf_token_name] => csrf_test_name
                                [csrf_cookie_name] => csrf_cookie_name
                                [csrf_expire] => 7200
                                [csrf_regenerate] => 1
                                [csrf_exclude_uris] => Array
                                    (
                                    )

                                [compress_output] => 
                                [time_reference] => local
                                [rewrite_short_tags] => 
                                [proxy_ips] => 
                                [mongo_db] => Array
                                    (
                                        [active_config_group] => default
                                        [default] => Array
                                            (
                                                [settings] => Array
                                                    (
                                                        [auth] => 1
                                                        [debug] => 1
                                                        [return_as] => array
                                                        [auto_reset_query] => 1
                                                    )

                                                [connection_string] => 
                                                [connection] => Array
                                                    (
                                                        [host] => 127.0.0.1
                                                        [port] => 27017
                                                        [user_name] => admin
                                                        [user_password] => admin
                                                        [db_name] => centralchronicle
                                                        [db_options] => Array
                                                            (
                                                            )

                                                    )

                                                [driver] => Array
                                                    (
                                                    )

                                            )

                                    )

                            )

                        [is_loaded] => Array
                            (
                                [0] => D:\xampp\htdocs\chronicle\application\config/mongo_db.php
                            )

                        [_config_paths] => Array
                            (
                                [0] => D:\xampp\htdocs\chronicle\application\
                            )

0 个答案:

没有答案