-
Notifications
You must be signed in to change notification settings - Fork 52
Can't connect to mongodb with Zend framework 1.12 #113
Comments
Hey, My bootstrap looks like: protected function _initDb() {
$config = Zend_Registry::get('config');
//Setup mongo
$connection = new Shanty_Mongo_Connection($config->mongo);
Shanty_Mongo::addMaster($connection);
Model_Mongo_Base::setDatabase($config->database);
} Then, in my config I simply have: mongodb://localhost:27017 |
Thank you very much. Can’t you send your config file to me? Thanks. Sent from Windows Mail From: Tom Holder Hey, My bootstrap looks like:
Then, in my config I simply have: mongodb://localhost:27017 — |
Hi Kevin, Not really it's got too much sensitive stuff in. Sorry that didn't post right though, it's just literally two config elements mongo (the connection string) and database (the database) |
Hi Tom, Thank you, can you tell me $config->database, what does it mean? Is it database's name? |
Hi Tom, And what is Model_Mongo_Base class, I can't find in Shanty folder? Please show me where is it. Thank you |
Hi Kevin, Sorry that's just a base class I inherit all my mongo doc classes from to give some shared functionality. class Model_Mongo_Base extends Shanty_Mongo_Document {
protected static $_db = 'contactzilla';
public static function setDatabase($db) {
self::$_db = $db;
} |
Hi Tom, Thanks a lot. It's worked. But When I call a model class it's give me the same error. I don't know what happen. Please help me. This is my Model. class Admin_Model_Post extends Shanty_Mongo_Document This is my Controller. class Admin_IndexController extends Zend_Controller_Action } Do I need to run MongoDB service? I don't know why but my MongoDB service can't start. But I still can connect to database using MongoVUE. |
This is the most basic you need: class User extends Shanty_Mongo_Document
{
protected static $_db = 'forum';
protected static $_collection = 'user';
} If that won't connect you might well have a problem with your mongo setup. |
I think the same as you, too. I'll check again the mongo setup and then I will post the solution to help another one have the same problem to me. Thank you very much, Tom. |
I don't know how to connect with Mongodb in Zend Framework althought I done exactly the tutorial. Please help me.
This is my boostrap file.
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDb()
{
//Setup mongo
$connection = new Shanty_Mongo_Connection("mongodb://admin:123456@localhost:27017");
$connection->setSlaveOkay(true);
Shanty_Mongo::addConnection($connection);
}
}
And this is what I got on my brwoser.

The text was updated successfully, but these errors were encountered: