Welcome Guest, Not a member yet? Register   Sign In
new codeigniter mongoDB library

I've just pushed on github the first release of my codeigniter library for interact with mongoDB.

let me know Smile


stable version is tagged on github:

mysql function in Codeigniter I Use list_field() to return an array containing the field names. What does the equivalent in mongoDB to return an array which contains he field name? This code below I use the list_field function

function GetField($execution) {
$query = $this->db->query($execution);
if ($query->num_rows() > 0) {
return $query->list_fields();
} else {
return array();

My goal is if there is input with complex queries, the field appears dynamically in accordance with the input query like using phpmyadmin in MySQL & rockmongo in mongoDB.
If there is no equivalent query in MongoDB, Is there a trick to solve my problem?
thanks in advance.

Hi zacksyah, the php mongoDb driver doesn't allow that, there is no list_fields() method.
Maybe because in mongo you can have subobjects...

you can use array_keys

If you want you can send me a pull req on github...
let me know Smile

The example of the method I gave above is not to MongoDB but for SQL. I mean, I want to create a simple application query executor like phpmyadmin(Just for create, update, deletr, read & searching data). Well the problem is how do I display the columns dynamically in accordance with the instructions given?
please help me.

a query with cimongo lib returns an object or array.
For example the array is a key=>value array.
key is your column name, value is the actual value for that row.
you can simply get every key on the first row and you have the column name.

so with your library, can I display the columns dynamically? Example the Query like this " db.users.find({'last_name': 'Smith'})"
the column that will appear is Last_name.

yes, you can get the column name with no problems

this is my sql executor that I mean
https://[email protected]/zacksyah/sql_executor.git
you can check the function GetField at model file, there is a list_field() function that I must change with mongoDB library in codeigniter. But I dont know how. Can you help me for mongoDB executor. thanks in advance

anyone can help my problem above

Theme © iAndrew 2016 - Forum software by © MyBB