• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
new codeigniter mongoDB library

#1
[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

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

#3
[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.

#4
[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

#5
[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.

#6
[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.

#7
[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.

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

#9
[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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.