Newbie question about multiple databases

2008-06-30 Thread rfflower

I'm a newbie trying to understand CAKE, and so far so good. I've
understood the 'blog' tutorial.
I am trying to make an app where users login and then use the app to
add their data to their own copy of a database. There would be lots of
databases (all same structure) each solely for that user.
I think I see how the useDbConfig bit works, but I'm a bit foggy about
how to go about it and how CAKE would expect the controllers, model,
views to be arranged, for all the different users.
If this isn't too trivial a question, can anyone point me in the right
direction?
Thanks in advance

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-11 Thread Sergei Gerasenko

I had an email hiccup yesterday, so I'm not sure if you got my last
message. Just in case I'll update you on what I've found. 

The bottom line is that it works in 1.1.11.4064 and doesn't in
1.1.14.4797. I don't know if a bug was introduced in 1.1.14, but I
guess it's possible.

Is there a way to inform the developers? The bug theory doesn't quite
stand since you were able to do it even with the alpha. What version of
php are you using?


On Tue, Apr 10, 2007 at 12:05:23PM -0400, Sergei Gerasenko wrote:
 
 OK, I duplicated the setup at work and everything went great. So there
 must be something with my setup at home. I'll try not to bug you guys
 about this anymore until I find out what's causing it.
 
 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-11 Thread Sergei Gerasenko

Well, it turns out that it's a bug that first appeared in 1.1.14. It
seems that it was first reported on the 8th. The ticket number is 2370.

On Wed, Apr 11, 2007 at 09:25:39AM -0400, Sergei Gerasenko wrote:
 
 I had an email hiccup yesterday, so I'm not sure if you got my last
 message. Just in case I'll update you on what I've found. 
 
 The bottom line is that it works in 1.1.11.4064 and doesn't in
 1.1.14.4797. I don't know if a bug was introduced in 1.1.14, but I
 guess it's possible.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-10 Thread Sergei Gerasenko

I think my directory structure is not quite right. Don't know how it
happened but I'm sure that's the reason. I'll check it tonight and let
you know.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-10 Thread Sergei Gerasenko

No, unfortunately that didn't help.

On Tue, Apr 10, 2007 at 11:29:44AM -0400, Sergei Gerasenko wrote:
 
 I think my directory structure is not quite right. Don't know how it
 happened but I'm sure that's the reason. I'll check it tonight and let
 you know.
 
 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-10 Thread Sergei Gerasenko

OK, I duplicated the setup at work and everything went great. So there
must be something with my setup at home. I'll try not to bug you guys
about this anymore until I find out what's causing it.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-10 Thread BlenderStyle

Two different servers can act differently. I have a SUSE LAMP server
at work and an Ubuntu LAMP server at home, and they experience
different issues. I think I must have compiled Apache and PHP
differently.

On Apr 10, 9:05 am, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
 OK, I duplicated the setup at work and everything went great. So there
 must be something with my setup at home. I'll try not to bug you guys
 about this anymore until I find out what's causing it.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread BlenderStyle

Yes, that should work. I haven't tried it, and I don't know how Cake
queries in a situation like this, but it doesn't hurt to try. Try it
out with scaffolding, and see if it works. Let us know.

On Apr 8, 1:49 pm, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
 On Sun, Apr 08, 2007 at 06:58:33PM -, BlenderStyle wrote:

  A brief overview.

  You need to create separate entries in your database config file, one
  for each database. In your model, specify which database to use. Then,
  in your controller, specify which models to use. You can use multiple
  models in your controller. If you need to know the specifics of each
  of these steps, search or ask here.

 Well, the problem I have is that in one of the models that belongs to
 database A I needed to include a belongsTo relationship with a model
 in database B. Is that possible?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread BlenderStyle

Okay, I just tried it, and it worked. Here's what I did:

Downloaded cake_1.2.0.4798alpha, extracted it, and made app/tmp
writeable.
I created the following databases/users/tables:

database: multidbtest_a
user: multidbtest_a
table: users (id, name)

database: multidbtest_b
user:multidbtest_b
table: profiles (id, user_id, name)

I setup app/config/database.php as follows:
var $default = array(
'driver' = 'mysql',
'persistent' = false,
'host' = 'localhost',
'login' = 'multidbtest_a',
'password' = 'NNJdALDhvm6Uqm8,',
'database' = 'multidbtest_a',
'prefix' = ''
);

var $dbb = array(
'driver' = 'mysql',
'persistent' = false,
'host' = 'localhost',
'login' = 'multidbtest_b',
'password' = ':.bwaJ6wXCDQs8Q:',
'database' = 'multidbtest_b',
'prefix' = ''
);

I created two models with two controllers. The first model is User:
class User extends AppModel
{
var $name = 'User';
var $useDbConfig = 'default';
var $useTable = 'users';

var $hasOne = array(
'Profile' = array(
'className' = 'Profile',
'foreignKey'= 'user_id'
)
);
}

The other model is Profile:
class Profile extends AppModel
{
var $name = 'Profile';
var $useDbConfig = 'dbb';
var $useTable = 'profiles';

var $belongsTo = array(
'User' = array(
'className' = 'User',
'foreignKey'= 'user_id'
)
);
}

Then, my two controllers:
class UsersController extends AppController
{
var $name = 'users';
var $scaffold;
}

class ProfilesController extends AppController
{
var $name = 'profiles';
var $scaffold;
}


I browsed to somesite.com/users and created a couple of users, then
went over to somesite.com/profiles and created some profiles for those
users. That's it. Took about 5 minutes to get this up and running. The
real key to making this work is the persistent key (ha! a pun) in the
database configs. I think 1.2 defaults to persistent false, where 1.1
doesn't.

Matt Bowden

On Apr 9, 10:10 am, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
  Yes, that should work. I haven't tried it, and I don't know how Cake
  queries in a situation like this, but it doesn't hurt to try. Try it
  out with scaffolding, and see if it works. Let us know.

 I think it would definitely stop working if database B has another
 username/password combination. This whole issue could throw a big wrench into
 the gears. But I'll try tonight anyway and will let you know.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread Sergei Gerasenko

Matt, thanks so much for all the time you took to test this thing. I
can see how it could work now. I'm off and running now. 

Thanks!!!

On Mon, Apr 09, 2007 at 07:59:26PM -, BlenderStyle wrote:
 
 Okay, I just tried it, and it worked. Here's what I did:
 
 Downloaded cake_1.2.0.4798alpha, extracted it, and made app/tmp
 writeable.
 I created the following databases/users/tables:
 
 database: multidbtest_a
 user: multidbtest_a
 table: users (id, name)
 
 database: multidbtest_b
 user:multidbtest_b
 table: profiles (id, user_id, name)
 
 I setup app/config/database.php as follows:
 var $default = array(
 'driver' = 'mysql',
 'persistent' = false,
 'host' = 'localhost',
 'login' = 'multidbtest_a',
 'password' = 'NNJdALDhvm6Uqm8,',
 'database' = 'multidbtest_a',
 'prefix' = ''
 );
 
 var $dbb = array(
 'driver' = 'mysql',
 'persistent' = false,
 'host' = 'localhost',
 'login' = 'multidbtest_b',
 'password' = ':.bwaJ6wXCDQs8Q:',
 'database' = 'multidbtest_b',
 'prefix' = ''
 );
 
 I created two models with two controllers. The first model is User:
 class User extends AppModel
 {
 var $name = 'User';
 var $useDbConfig = 'default';
 var $useTable = 'users';
 
 var $hasOne = array(
 'Profile' = array(
 'className'   = 'Profile',
 'foreignKey'  = 'user_id'
 )
 );
 }
 
 The other model is Profile:
 class Profile extends AppModel
 {
 var $name = 'Profile';
 var $useDbConfig = 'dbb';
 var $useTable = 'profiles';
 
 var $belongsTo = array(
 'User' = array(
 'className'   = 'User',
 'foreignKey'  = 'user_id'
 )
 );
 }
 
 Then, my two controllers:
 class UsersController extends AppController
 {
 var $name = 'users';
 var $scaffold;
 }
 
 class ProfilesController extends AppController
 {
 var $name = 'profiles';
 var $scaffold;
 }
 
 
 I browsed to somesite.com/users and created a couple of users, then
 went over to somesite.com/profiles and created some profiles for those
 users. That's it. Took about 5 minutes to get this up and running. The
 real key to making this work is the persistent key (ha! a pun) in the
 database configs. I think 1.2 defaults to persistent false, where 1.1
 doesn't.
 
 Matt Bowden
 
 On Apr 9, 10:10 am, Sergei Gerasenko [EMAIL PROTECTED]
 wrote:
   Yes, that should work. I haven't tried it, and I don't know how Cake
   queries in a situation like this, but it doesn't hurt to try. Try it
   out with scaffolding, and see if it works. Let us know.
 
  I think it would definitely stop working if database B has another
  username/password combination. This whole issue could throw a big wrench 
  into
  the gears. But I'll try tonight anyway and will let you know.
 
 
  

-- 

Sergei Gerasenko
IT Department
PublicSchoolWORKS
Phone: (513)-631-6111

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread BlenderStyle

You're welcome. In doing this, I learned about the persistent key, so
everyone wins. Let us know how it goes.

On Apr 9, 1:15 pm, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
 Matt, thanks so much for all the time you took to test this thing. I
 can see how it could work now. I'm off and running now.

 Thanks!!!



 On Mon, Apr 09, 2007 at 07:59:26PM -, BlenderStyle wrote:

  Okay, I just tried it, and it worked. Here's what I did:

  Downloaded cake_1.2.0.4798alpha, extracted it, and made app/tmp
  writeable.
  I created the following databases/users/tables:

  database: multidbtest_a
  user: multidbtest_a
  table: users (id, name)

  database: multidbtest_b
  user:multidbtest_b
  table: profiles (id, user_id, name)

  I setup app/config/database.php as follows:
  var $default = array(
  'driver' = 'mysql',
  'persistent' = false,
  'host' = 'localhost',
  'login' = 'multidbtest_a',
  'password' = 'NNJdALDhvm6Uqm8,',
  'database' = 'multidbtest_a',
  'prefix' = ''
  );

  var $dbb = array(
  'driver' = 'mysql',
  'persistent' = false,
  'host' = 'localhost',
  'login' = 'multidbtest_b',
  'password' = ':.bwaJ6wXCDQs8Q:',
  'database' = 'multidbtest_b',
  'prefix' = ''
  );

  I created two models with two controllers. The first model is User:
  class User extends AppModel
  {
  var $name = 'User';
  var $useDbConfig = 'default';
  var $useTable = 'users';

  var $hasOne = array(
  'Profile' = array(
  'className'= 'Profile',
  'foreignKey'   = 'user_id'
  )
  );
  }

  The other model is Profile:
  class Profile extends AppModel
  {
  var $name = 'Profile';
  var $useDbConfig = 'dbb';
  var $useTable = 'profiles';

  var $belongsTo = array(
  'User' = array(
  'className'= 'User',
  'foreignKey'   = 'user_id'
  )
  );
  }

  Then, my two controllers:
  class UsersController extends AppController
  {
  var $name = 'users';
  var $scaffold;
  }

  class ProfilesController extends AppController
  {
  var $name = 'profiles';
  var $scaffold;
  }

  I browsed to somesite.com/users and created a couple of users, then
  went over to somesite.com/profiles and created some profiles for those
  users. That's it. Took about 5 minutes to get this up and running. The
  real key to making this work is the persistent key (ha! a pun) in the
  database configs. I think 1.2 defaults to persistent false, where 1.1
  doesn't.

  Matt Bowden

  On Apr 9, 10:10 am, Sergei Gerasenko [EMAIL PROTECTED]
  wrote:
Yes, that should work. I haven't tried it, and I don't know how Cake
queries in a situation like this, but it doesn't hurt to try. Try it
out with scaffolding, and see if it works. Let us know.

   I think it would definitely stop working if database B has another
   username/password combination. This whole issue could throw a big wrench 
   into
   the gears. But I'll try tonight anyway and will let you know.

 --

 Sergei Gerasenko
 IT Department
 PublicSchoolWORKS
 Phone: (513)-631-6111


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread Sergei Gerasenko

I must admit that I should have asked you about what you found about
the persistent key thingy. Should it be set to false in this
situation? And if so, why do you think it's the case? Sorry if it sounds
like an interview question :)

On Mon, Apr 09, 2007 at 08:49:17PM -, BlenderStyle wrote:
 
 You're welcome. In doing this, I learned about the persistent key, so
 everyone wins. Let us know how it goes.
 
 On Apr 9, 1:15 pm, Sergei Gerasenko [EMAIL PROTECTED]
 wrote:
  Matt, thanks so much for all the time you took to test this thing. I
  can see how it could work now. I'm off and running now.
 
  Thanks!!!
 
 
 
  On Mon, Apr 09, 2007 at 07:59:26PM -, BlenderStyle wrote:
 
   Okay, I just tried it, and it worked. Here's what I did:
 
   Downloaded cake_1.2.0.4798alpha, extracted it, and made app/tmp
   writeable.
   I created the following databases/users/tables:
 
   database: multidbtest_a
   user: multidbtest_a
   table: users (id, name)
 
   database: multidbtest_b
   user:multidbtest_b
   table: profiles (id, user_id, name)
 
   I setup app/config/database.php as follows:
   var $default = array(
   'driver' = 'mysql',
   'persistent' = false,
   'host' = 'localhost',
   'login' = 'multidbtest_a',
   'password' = 'NNJdALDhvm6Uqm8,',
   'database' = 'multidbtest_a',
   'prefix' = ''
   );
 
   var $dbb = array(
   'driver' = 'mysql',
   'persistent' = false,
   'host' = 'localhost',
   'login' = 'multidbtest_b',
   'password' = ':.bwaJ6wXCDQs8Q:',
   'database' = 'multidbtest_b',
   'prefix' = ''
   );
 
   I created two models with two controllers. The first model is User:
   class User extends AppModel
   {
   var $name = 'User';
   var $useDbConfig = 'default';
   var $useTable = 'users';
 
   var $hasOne = array(
   'Profile' = array(
   'className'= 'Profile',
   'foreignKey'   = 'user_id'
   )
   );
   }
 
   The other model is Profile:
   class Profile extends AppModel
   {
   var $name = 'Profile';
   var $useDbConfig = 'dbb';
   var $useTable = 'profiles';
 
   var $belongsTo = array(
   'User' = array(
   'className'= 'User',
   'foreignKey'   = 'user_id'
   )
   );
   }
 
   Then, my two controllers:
   class UsersController extends AppController
   {
   var $name = 'users';
   var $scaffold;
   }
 
   class ProfilesController extends AppController
   {
   var $name = 'profiles';
   var $scaffold;
   }
 
   I browsed to somesite.com/users and created a couple of users, then
   went over to somesite.com/profiles and created some profiles for those
   users. That's it. Took about 5 minutes to get this up and running. The
   real key to making this work is the persistent key (ha! a pun) in the
   database configs. I think 1.2 defaults to persistent false, where 1.1
   doesn't.
 
   Matt Bowden
 
   On Apr 9, 10:10 am, Sergei Gerasenko [EMAIL PROTECTED]
   wrote:
 Yes, that should work. I haven't tried it, and I don't know how Cake
 queries in a situation like this, but it doesn't hurt to try. Try it
 out with scaffolding, and see if it works. Let us know.
 
I think it would definitely stop working if database B has another
username/password combination. This whole issue could throw a big 
wrench into
the gears. But I'll try tonight anyway and will let you know.
 
  --
 
  Sergei Gerasenko
  IT Department
  PublicSchoolWORKS
  Phone: (513)-631-6111
 
 
  

-- 

Sergei Gerasenko
IT Department
PublicSchoolWORKS
Phone: (513)-631-6111

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread Sergei Gerasenko

 You're welcome. In doing this, I learned about the persistent key, so
 everyone wins. Let us know how it goes.

Just tried this at home and I'm baffled with this error: Cannot redeclare class 
dbosource in /var/www/cake/cake/libs/model/datasources/dbo_source.php

Here's my setup:

app/config/database.php:
===

  var $psw = array('driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'localhost',
'login' = '***',
'password' = '***',
'database' = 'psw',
'persistent' = false,
'prefix' = '');

  var $pbs = array('driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'localhost',
'login' = '***',
'password' = '***',
'database' = 'pbs',
'persistent' = false,
'prefix' = '');



app/models/student.php
===
?
class Student extends AppModel
{
  var $name = 'Student';
  var $useDbConfig = 'pbs';

  var $belongsTo = array(
'Customer' = array('className' = 'Customer')
  );
}
?

app/models/customer.php
===
?
class Customer extends AppModel
{
  var $name = 'Customer';
  var $useDbConfig = 'psw';
}
?

Am I missing something?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread BlenderStyle

I ran into this too. One of the database configs has to be default. So
change $psw to $default, and remove var $useConfig in your customer
model (it uses default by, well, default).

If persistent is set to true,  you can't use two configs
simultaneously. I'm guessing if persistent is true, and the default
database config (host, username, password, database) is used, it keeps
that connection open. Then, when your other model comes into play it
will try to use the same connection.

On Apr 9, 4:15 pm, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
  You're welcome. In doing this, I learned about the persistent key, so
  everyone wins. Let us know how it goes.

 Just tried this at home and I'm baffled with this error: Cannot redeclare 
 class dbosource in /var/www/cake/cake/libs/model/datasources/dbo_source.php

 Here's my setup:

 app/config/database.php:
 ===

   var $psw = array('driver' = 'mysql',
 'connect' = 'mysql_connect',
 'host' = 'localhost',
 'login' = '***',
 'password' = '***',
 'database' = 'psw',
 'persistent' = false,
 'prefix' = '');

   var $pbs = array('driver' = 'mysql',
 'connect' = 'mysql_connect',
 'host' = 'localhost',
 'login' = '***',
 'password' = '***',
 'database' = 'pbs',
 'persistent' = false,
 'prefix' = '');

 app/models/student.php
 ===
 ?
 class Student extends AppModel
 {
   var $name = 'Student';
   var $useDbConfig = 'pbs';

   var $belongsTo = array(
 'Customer' = array('className' = 'Customer')
   );}

 ?

 app/models/customer.php
 ===
 ?
 class Customer extends AppModel
 {
   var $name = 'Customer';
   var $useDbConfig = 'psw';}

 ?

 Am I missing something?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread Sergei Gerasenko

Thanks for the quick response. Unfortunately, that didn't do it.

Here's the modified app/config/database.php

class DATABASE_CONFIG
{
  var $default = array('driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'localhost',
'login' = '***',
'password' = '***',
'database' = 'publicschoolworks',
'persistent' = false,
'prefix' = '');

  var $pbs = array('driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'localhost',
'login' = '***',
'password' = '***',
'database' = 'pbs',
'persistent' = false,
'prefix' = '');

  var $test = array('driver' = 'mysql',
  'connect' = 'mysql_connect',
  'host' = 'localhost',
  'login' = 'user',
  'password' = 'password',
  'database' = 'project_name-test',
  'prefix' = '');
}

And the models:

?
class Customer extends AppModel
{
  var $name = 'Customer';
}
?

?
class Student extends AppModel
{
  var $name = 'Student';
  var $useDbConfig = 'pbs';

  var $belongsTo = array(
'Customer' = array('className' = 'Customer')
  );
}
?

Let me know if you can think of something else.

Thanks,
  Sergei

On Tue, Apr 10, 2007 at 12:05:05AM -, BlenderStyle wrote:
 
 I ran into this too. One of the database configs has to be default. So
 change $psw to $default, and remove var $useConfig in your customer
 model (it uses default by, well, default).
 
 If persistent is set to true,  you can't use two configs
 simultaneously. I'm guessing if persistent is true, and the default
 database config (host, username, password, database) is used, it keeps
 that connection open. Then, when your other model comes into play it
 will try to use the same connection.
 
 On Apr 9, 4:15 pm, Sergei Gerasenko [EMAIL PROTECTED]
 wrote:
   You're welcome. In doing this, I learned about the persistent key, so
   everyone wins. Let us know how it goes.
 
  Just tried this at home and I'm baffled with this error: Cannot redeclare 
  class dbosource in /var/www/cake/cake/libs/model/datasources/dbo_source.php
 
  Here's my setup:
 
  app/config/database.php:
  ===
 
var $psw = array('driver' = 'mysql',
  'connect' = 'mysql_connect',
  'host' = 'localhost',
  'login' = '***',
  'password' = '***',
  'database' = 'psw',
  'persistent' = false,
  'prefix' = '');
 
var $pbs = array('driver' = 'mysql',
  'connect' = 'mysql_connect',
  'host' = 'localhost',
  'login' = '***',
  'password' = '***',
  'database' = 'pbs',
  'persistent' = false,
  'prefix' = '');
 
  app/models/student.php
  ===
  ?
  class Student extends AppModel
  {
var $name = 'Student';
var $useDbConfig = 'pbs';
 
var $belongsTo = array(
  'Customer' = array('className' = 'Customer')
);}
 
  ?
 
  app/models/customer.php
  ===
  ?
  class Customer extends AppModel
  {
var $name = 'Customer';
var $useDbConfig = 'psw';}
 
  ?
 
  Am I missing something?
 
 
  

-- 

Sergei Gerasenko
IT Department
PublicSchoolWORKS
Phone: (513)-631-6111

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread BlenderStyle

What version of Cake are you using?

On Apr 9, 5:40 pm, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
 Thanks for the quick response. Unfortunately, that didn't do it.

 Here's the modified app/config/database.php

 class DATABASE_CONFIG
 {
   var $default = array('driver' = 'mysql',
 'connect' = 'mysql_connect',
 'host' = 'localhost',
 'login' = '***',
 'password' = '***',
 'database' = 'publicschoolworks',
 'persistent' = false,
 'prefix' = '');

   var $pbs = array('driver' = 'mysql',
 'connect' = 'mysql_connect',
 'host' = 'localhost',
 'login' = '***',
 'password' = '***',
 'database' = 'pbs',
 'persistent' = false,
 'prefix' = '');

   var $test = array('driver' = 'mysql',
   'connect' = 'mysql_connect',
   'host' = 'localhost',
   'login' = 'user',
   'password' = 'password',
   'database' = 'project_name-test',
   'prefix' = '');

 }

 And the models:

 ?
 class Customer extends AppModel
 {
   var $name = 'Customer';}

 ?

 ?
 class Student extends AppModel
 {
   var $name = 'Student';
   var $useDbConfig = 'pbs';

   var $belongsTo = array(
 'Customer' = array('className' = 'Customer')
   );}

 ?

 Let me know if you can think of something else.

 Thanks,
   Sergei



 On Tue, Apr 10, 2007 at 12:05:05AM -, BlenderStyle wrote:

  I ran into this too. One of the database configs has to be default. So
  change $psw to $default, and remove var $useConfig in your customer
  model (it uses default by, well, default).

  If persistent is set to true,  you can't use two configs
  simultaneously. I'm guessing if persistent is true, and the default
  database config (host, username, password, database) is used, it keeps
  that connection open. Then, when your other model comes into play it
  will try to use the same connection.

  On Apr 9, 4:15 pm, Sergei Gerasenko [EMAIL PROTECTED]
  wrote:
You're welcome. In doing this, I learned about the persistent key, so
everyone wins. Let us know how it goes.

   Just tried this at home and I'm baffled with this error: Cannot redeclare 
   class dbosource in 
   /var/www/cake/cake/libs/model/datasources/dbo_source.php

   Here's my setup:

   app/config/database.php:
   ===

 var $psw = array('driver' = 'mysql',
   'connect' = 'mysql_connect',
   'host' = 'localhost',
   'login' = '***',
   'password' = '***',
   'database' = 'psw',
   'persistent' = false,
   'prefix' = '');

 var $pbs = array('driver' = 'mysql',
   'connect' = 'mysql_connect',
   'host' = 'localhost',
   'login' = '***',
   'password' = '***',
   'database' = 'pbs',
   'persistent' = false,
   'prefix' = '');

   app/models/student.php
   ===
   ?
   class Student extends AppModel
   {
 var $name = 'Student';
 var $useDbConfig = 'pbs';

 var $belongsTo = array(
   'Customer' = array('className' = 'Customer')
 );}

   ?

   app/models/customer.php
   ===
   ?
   class Customer extends AppModel
   {
 var $name = 'Customer';
 var $useDbConfig = 'psw';}

   ?

   Am I missing something?

 --

 Sergei Gerasenko
 IT Department
 PublicSchoolWORKS
 Phone: (513)-631-6111


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread Sergei Gerasenko

I was using 1.1.14 but then when I got the error I tried the
1.2.0.4798-alpha. That is, I replaced the 1.1.14 cake directory
with the cake directory from the alpha distribution.

On Tue, Apr 10, 2007 at 12:46:22AM -, BlenderStyle wrote:
 
 What version of Cake are you using?
 
 On Apr 9, 5:40 pm, Sergei Gerasenko [EMAIL PROTECTED]
 wrote:
  Thanks for the quick response. Unfortunately, that didn't do it.
 
  Here's the modified app/config/database.php
 
  class DATABASE_CONFIG
  {
var $default = array('driver' = 'mysql',
  'connect' = 'mysql_connect',
  'host' = 'localhost',
  'login' = '***',
  'password' = '***',
  'database' = 'publicschoolworks',
  'persistent' = false,
  'prefix' = '');
 
var $pbs = array('driver' = 'mysql',
  'connect' = 'mysql_connect',
  'host' = 'localhost',
  'login' = '***',
  'password' = '***',
  'database' = 'pbs',
  'persistent' = false,
  'prefix' = '');
 
var $test = array('driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'localhost',
'login' = 'user',
'password' = 'password',
'database' = 'project_name-test',
'prefix' = '');
 
  }
 
  And the models:
 
  ?
  class Customer extends AppModel
  {
var $name = 'Customer';}
 
  ?
 
  ?
  class Student extends AppModel
  {
var $name = 'Student';
var $useDbConfig = 'pbs';
 
var $belongsTo = array(
  'Customer' = array('className' = 'Customer')
);}
 
  ?
 
  Let me know if you can think of something else.
 
  Thanks,
Sergei
 
 
 
  On Tue, Apr 10, 2007 at 12:05:05AM -, BlenderStyle wrote:
 
   I ran into this too. One of the database configs has to be default. So
   change $psw to $default, and remove var $useConfig in your customer
   model (it uses default by, well, default).
 
   If persistent is set to true,  you can't use two configs
   simultaneously. I'm guessing if persistent is true, and the default
   database config (host, username, password, database) is used, it keeps
   that connection open. Then, when your other model comes into play it
   will try to use the same connection.
 
   On Apr 9, 4:15 pm, Sergei Gerasenko [EMAIL PROTECTED]
   wrote:
 You're welcome. In doing this, I learned about the persistent key, so
 everyone wins. Let us know how it goes.
 
Just tried this at home and I'm baffled with this error: Cannot 
redeclare class dbosource in 
/var/www/cake/cake/libs/model/datasources/dbo_source.php
 
Here's my setup:
 
app/config/database.php:
===
 
  var $psw = array('driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'localhost',
'login' = '***',
'password' = '***',
'database' = 'psw',
'persistent' = false,
'prefix' = '');
 
  var $pbs = array('driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'localhost',
'login' = '***',
'password' = '***',
'database' = 'pbs',
'persistent' = false,
'prefix' = '');
 
app/models/student.php
===
?
class Student extends AppModel
{
  var $name = 'Student';
  var $useDbConfig = 'pbs';
 
  var $belongsTo = array(
'Customer' = array('className' = 'Customer')
  );}
 
?
 
app/models/customer.php
===
?
class Customer extends AppModel
{
  var $name = 'Customer';
  var $useDbConfig = 'psw';}
 
?
 
Am I missing something?
 
  --
 
  Sergei Gerasenko
  IT Department
  PublicSchoolWORKS
  Phone: (513)-631-6111
 
 
  

-- 

Sergei Gerasenko
IT Department
PublicSchoolWORKS
Phone: (513)-631-6111

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-09 Thread BlenderStyle

Did migrating to 1.2.0.4798alpha fix your problem? I've found, that
even though it's an alpha, 1.2 works pretty well.

On Apr 9, 6:06 pm, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
 I was using 1.1.14 but then when I got the error I tried the
 1.2.0.4798-alpha. That is, I replaced the 1.1.14 cake directory
 with the cake directory from the alpha distribution.



 On Tue, Apr 10, 2007 at 12:46:22AM -, BlenderStyle wrote:

  What version of Cake are you using?

  On Apr 9, 5:40 pm, Sergei Gerasenko [EMAIL PROTECTED]
  wrote:
   Thanks for the quick response. Unfortunately, that didn't do it.

   Here's the modified app/config/database.php

   class DATABASE_CONFIG
   {
 var $default = array('driver' = 'mysql',
   'connect' = 'mysql_connect',
   'host' = 'localhost',
   'login' = '***',
   'password' = '***',
   'database' = 'publicschoolworks',
   'persistent' = false,
   'prefix' = '');

 var $pbs = array('driver' = 'mysql',
   'connect' = 'mysql_connect',
   'host' = 'localhost',
   'login' = '***',
   'password' = '***',
   'database' = 'pbs',
   'persistent' = false,
   'prefix' = '');

 var $test = array('driver' = 'mysql',
 'connect' = 'mysql_connect',
 'host' = 'localhost',
 'login' = 'user',
 'password' = 'password',
 'database' = 'project_name-test',
 'prefix' = '');

   }

   And the models:

   ?
   class Customer extends AppModel
   {
 var $name = 'Customer';}

   ?

   ?
   class Student extends AppModel
   {
 var $name = 'Student';
 var $useDbConfig = 'pbs';

 var $belongsTo = array(
   'Customer' = array('className' = 'Customer')
 );}

   ?

   Let me know if you can think of something else.

   Thanks,
 Sergei

   On Tue, Apr 10, 2007 at 12:05:05AM -, BlenderStyle wrote:

I ran into this too. One of the database configs has to be default. So
change $psw to $default, and remove var $useConfig in your customer
model (it uses default by, well, default).

If persistent is set to true,  you can't use two configs
simultaneously. I'm guessing if persistent is true, and the default
database config (host, username, password, database) is used, it keeps
that connection open. Then, when your other model comes into play it
will try to use the same connection.

On Apr 9, 4:15 pm, Sergei Gerasenko [EMAIL PROTECTED]
wrote:
  You're welcome. In doing this, I learned about the persistent key, 
  so
  everyone wins. Let us know how it goes.

 Just tried this at home and I'm baffled with this error: Cannot 
 redeclare class dbosource in 
 /var/www/cake/cake/libs/model/datasources/dbo_source.php

 Here's my setup:

 app/config/database.php:
 ===

   var $psw = array('driver' = 'mysql',
 'connect' = 'mysql_connect',
 'host' = 'localhost',
 'login' = '***',
 'password' = '***',
 'database' = 'psw',
 'persistent' = false,
 'prefix' = '');

   var $pbs = array('driver' = 'mysql',
 'connect' = 'mysql_connect',
 'host' = 'localhost',
 'login' = '***',
 'password' = '***',
 'database' = 'pbs',
 'persistent' = false,
 'prefix' = '');

 app/models/student.php
 ===
 ?
 class Student extends AppModel
 {
   var $name = 'Student';
   var $useDbConfig = 'pbs';

   var $belongsTo = array(
 'Customer' = array('className' = 'Customer')
   );}

 ?

 app/models/customer.php
 ===
 ?
 class Customer extends AppModel
 {
   var $name = 'Customer';
   var $useDbConfig = 'psw';}

 ?

 Am I missing something?

   --

   Sergei Gerasenko
   IT Department
   PublicSchoolWORKS
   Phone: (513)-631-6111

 --

 Sergei Gerasenko
 IT Department
 PublicSchoolWORKS
 Phone: (513)-631-6111


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



newbie question about multiple databases

2007-04-08 Thread [EMAIL PROTECTED]

Hmm, I posted this a couple of hours ago but couldn't find it in the
post list. So, I'm posting it again. Sorry if this is the second time
you guys are getting it.

===
Hi everybody,

I'm considering converting my application into CakePHP.

Currently I have 3 databases within my application and the first one
has several tables that are referenced by tables in the other two
databases.

Problem 1. I have tables that are named the same in at least two
databases. Can models, controllers and views be isolated to a folder
that would correspond to a specific database? Cake Views are already
in a folder by the controller name but models and controllers exist in
the same directories.

Problem 2. I don't know how to describe a model that has a
relationship to a table from a different database.

What's the best way to handle this situation in Cake?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-08 Thread BlenderStyle

A brief overview.

You need to create separate entries in your database config file, one
for each database. In your model, specify which database to use. Then,
in your controller, specify which models to use. You can use multiple
models in your controller. If you need to know the specifics of each
of these steps, search or ask here.

Matt

On Apr 8, 9:09 am, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hmm, I posted this a couple of hours ago but couldn't find it in the
 post list. So, I'm posting it again. Sorry if this is the second time
 you guys are getting it.

 ===
 Hi everybody,

 I'm considering converting my application into CakePHP.

 Currently I have 3 databases within my application and the first one
 has several tables that are referenced by tables in the other two
 databases.

 Problem 1. I have tables that are named the same in at least two
 databases. Can models, controllers and views be isolated to a folder
 that would correspond to a specific database? Cake Views are already
 in a folder by the controller name but models and controllers exist in
 the same directories.

 Problem 2. I don't know how to describe a model that has a
 relationship to a table from a different database.

 What's the best way to handle this situation in Cake?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: newbie question about multiple databases

2007-04-08 Thread Sergei Gerasenko

On Sun, Apr 08, 2007 at 06:58:33PM -, BlenderStyle wrote:
 
 A brief overview.
 
 You need to create separate entries in your database config file, one
 for each database. In your model, specify which database to use. Then,
 in your controller, specify which models to use. You can use multiple
 models in your controller. If you need to know the specifics of each
 of these steps, search or ask here.

Well, the problem I have is that in one of the models that belongs to
database A I needed to include a belongsTo relationship with a model
in database B. Is that possible?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---