I have connected my php web app to mongodb with the help of codeigniter driver.
now i am using the mongoo_db class to insert a collection into the default database, db_name.
the source code of my files is,
ghy.php
<?php
/**
* @author
* @copyright 2014
*/
class ghy
{
public $id;
public $name;
public function insert($collection = "", $data = array()) {
if(empty($collection))
show_error("No Mongo collection selected to insert into", 500);
if(count($data) == 0 || !is_array($data))
show_error("Nothing to insert into Mongo collection or insert is not an array", 500);
try {
$this->db->{$collection}->insert($insert, array('safe' => TRUE));
if(isset($insert['_id']))
return($insert['_id']);
else
return(FALSE);
} catch(MongoCursorException $e) {
show_error("Insert of data into MongoDB failed: {$e->getMessage()}", 500);
}
$use=$this->mongo_db->insert('foo', $data = array('4','hgfh'));
var_dump();
}
}
?>
the problem is that i am not getting any output in my browser.
can anyone plss explain me where am i going wrong? replies at the the earliest will be highly appreciated.
thankyou