Friday, June 3, 2011

How to pass variable out of datasource

Hi,

I have not been developing with cake for long, but from what I have
used so far I can certainly see how good it is!

For a project I have just started on, I wanted to hook up a new
datasource that would allow me to connect to the rackspace cloud.

I dutifully set up a new datasource and with a little bit of 'pr()'
inside the datasource, found I was able to connect succesfully.

The problem is that I need to pass the variable created when
establishing the connection out, for use in the controller?

e.g. it may be esablished in the datasource like so:

class CloudfilesSource extends DataSource {
public $conn;
public function __construct($config) {
parent::__construct($config);
$auth = ***;
$auth->authenticate();
$conn = new CF_Connection($auth);
$this->conn = $conn;
}
}

but how can I access this $conn outside of the datasource? I though I
would just be a case of $this->Model->conn but this just doesn't work!

Any help appreciated

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: