CodeIgniter Forums

Full Version: new codeigniter mongoDB library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]vesparny[/eluser]
I've just pushed on github the first release of my codeigniter library for interact with mongoDB.

let me know Smile

https://github.com/vesparny/cimongo-code...db-library

El Forum

[eluser]vesparny[/eluser]
stable version is tagged on github:
https://github.com/vesparny/cimongo-code...brary/tags

El Forum

[eluser]zacksyah[/eluser]
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.

El Forum

[eluser]vesparny[/eluser]
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
http://php.net/manual/en/function.array-keys.php.

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

El Forum

[eluser]zacksyah[/eluser]
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.

El Forum

[eluser]vesparny[/eluser]
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.

El Forum

[eluser]zacksyah[/eluser]
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.

El Forum

[eluser]vesparny[/eluser]
yes, you can get the column name with no problems

El Forum

[eluser]zacksyah[/eluser]
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

El Forum

[eluser]zacksyah[/eluser]
anyone can help my problem above