Re: CakePHP 3 - Where is custom datasource ?

2015-09-06 Thread Rahul Singh
Salines <nikola.paradzik@...> writes:

> 
> 
> 
> Hi,
> 
> I have a large number of CakePHP 2 web applications, many of them use 
remote data over the DataSource. I'm reading the documentation of CakePHP 
3, but I can not find instructions for remote datesource.
> 
> My next project also requires a custom DataSource (ArangoDB), so I 
planned to build it with the new version of CakePHP.
> 
> Please do specify where and how to build a DataSource in CakePHP 3.
> 
> Thank You.
> 
> 
> 
> 


I needed the custom datasources too, so I created a ArangoModel for 
CakaPHP 3.x check the repo.

https://github.com/raulsi/CakePHP-ArangoDb.git



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3 - Where is custom datasource ?

2015-04-03 Thread Salines
Ok, thank you.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3 - Where is custom datasource ?

2015-04-03 Thread mark_story
The custom datasource approach from 2.x had a number of drawbacks and leaky 
abstractions which we decided we didn't want to bring forward. 

The new orm focuses on being really great for sql based datastores, and we felt 
it would be impossible to provide great sql support and every other kind of 
datasource. Instead custom datasources that don't use sql should provide an 
implementation of the RepositoryInterface, a query builder and possible a 
specialized entity object.

Unfortunately, there aren't many examples of this approach in the wild. There 
is an incomplete start on an elasticsearch plugin in the cakephp github account 
but it is nowhere near complete.

-mark

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3 - Where is custom datasource ?

2015-04-02 Thread Salines
Hi,

I have a large number of CakePHP 2 web applications, many of them use 
remote data over the DataSource. I'm reading the documentation of CakePHP 
3, but I can not find instructions for remote datesource.

My next project also requires a custom DataSource (ArangoDB), so I planned 
to build it with the new version of CakePHP.

Please do specify where and how to build a DataSource in CakePHP 3.

Thank You.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


problems with custom datasource

2011-12-28 Thread flosky
Hi everyone,

I am writing a custom datasource with cake 2.x to get data from an api
call.
I did everything according to the twitter example in the book.
But when I run a Model-find('all') I get following error message:

Error: Database table examples for model Example was not found.

I suspect something wrong in the code of the DataSource.
This is my code for the DataSource (as you can see its pretty much
dummy code, just to get it working):

class ExampleSource extends DataSource {
 protected $_schema = array(
'tweets' = array(
'id' = array(
'type' = 'integer',
'null' = true,
'key' = 'primary',
'length' = 11,
),
'text' = array(
'type' = 'string',
'null' = true,
'key' = 'primary',
'length' = 140
),
'status' = array(
'type' = 'string',
'null' = true,
'key' = 'primary',
'length' = 140
),
)
);

/**
 * Constructor
 *
 */
public function __construct($config) {
parent::__construct($config);
}

public function read($model, $queryData = array()) {
return array('nothing' = array('id' = 1, 'text' = 'nothing',
'status' = 'success'));
}

 public function listSources() {
return array('tweets');
}

public function describe($model) {
return $this-_schema['tweets'];
}
}
?


Any hints?

Thanks, flosky

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Custom Datasource

2011-11-15 Thread RhythmicDevil
Hi All,
I am having some issues understanding the naming conventions for a
custom datasource.

datasource file name: gti_api_source.php
class name GtiApiSource


Database Config

var $gti_api = array(
'driver' = 'gti_api',
'url' = 'http://swright-dev:1337/',
);


Model

public $useDbConfig = 'gti_api';
public $useTable = false;


This is giving me errors. I did a var dump in
ConnectionManager::loadDataSource to see what it was asking for. I get
this:

array
  'filename' = string 'dbo/dbo_gti_api' (length=15)
  'classname' = string 'DboGtiApi' (length=9)
  'parent' =
array
  'filename' = string 'dbo_source' (length=10)
  'classname' = string 'DboSource' (length=9)
  'parent' = null
  'plugin' = null
  'plugin' = null
array
  'filename' = string 'dbo_source' (length=10)
  'classname' = string 'DboSource' (length=9)
  'parent' = null
  'plugin' = null
Fatal Error (256): ConnectionManager::loadDataSource - Unable to
import DataSource class .DboGtiApi [CORE/cake/libs/model/
connection_manager.php, line 185


I believe the problem is that I am defining a driver so the connection
tacks on the Dbo string to my class names and then looks for a driver.
This does not exist so it dies. I removed the driver definition from
the database def:

var $gti_api = array(
'url' = 'http://swright-dev:1337/',
);

And now I get this error:

array
  'filename' = string 'dbo_source' (length=10)
  'classname' = string 'DboSource' (length=9)
  'parent' = null
  'plugin' = null

( ! ) Fatal error: Call to undefined method DboSource::connect() in /
var/www/html/_libraries/cake_1_3/cake/libs/model/datasources/
dbo_source.php on line 143

So its still apparently wrong. The examples on the Cake site
http://book.cakephp.org/view/1077/An-Example dont really speak to
this.

Does anyone know where I am going wrong?

Thanks
Steve

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Custom Datasource

2011-11-15 Thread RhythmicDevil
So I was using the wrong model method. I was using Model::read()
instead of Model::find(). Read did not throw an error. But Find()
does.

Now I get this: Datasource class gti could not be found.


On Nov 15, 10:26 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 Hi All,
 I am having some issues understanding the naming conventions for a
 custom datasource.

 datasource file name: gti_api_source.php
 class name GtiApiSource

 Database Config

         var $gti_api = array(
             'driver' = 'gti_api',
             'url' = 'http://swright-dev:1337/',
         );

 Model

     public $useDbConfig = 'gti_api';
     public $useTable = false;

 This is giving me errors. I did a var dump in
 ConnectionManager::loadDataSource to see what it was asking for. I get
 this:

 array
   'filename' = string 'dbo/dbo_gti_api' (length=15)
   'classname' = string 'DboGtiApi' (length=9)
   'parent' =
     array
       'filename' = string 'dbo_source' (length=10)
       'classname' = string 'DboSource' (length=9)
       'parent' = null
       'plugin' = null
   'plugin' = null
 array
   'filename' = string 'dbo_source' (length=10)
   'classname' = string 'DboSource' (length=9)
   'parent' = null
   'plugin' = null
 Fatal Error (256): ConnectionManager::loadDataSource - Unable to
 import DataSource class .DboGtiApi [CORE/cake/libs/model/
 connection_manager.php, line 185

 I believe the problem is that I am defining a driver so the connection
 tacks on the Dbo string to my class names and then looks for a driver.
 This does not exist so it dies. I removed the driver definition from
 the database def:

         var $gti_api = array(
             'url' = 'http://swright-dev:1337/',
         );

 And now I get this error:

 array
   'filename' = string 'dbo_source' (length=10)
   'classname' = string 'DboSource' (length=9)
   'parent' = null
   'plugin' = null

 ( ! ) Fatal error: Call to undefined method DboSource::connect() in /
 var/www/html/_libraries/cake_1_3/cake/libs/model/datasources/
 dbo_source.php on line 143

 So its still apparently wrong. The examples on the Cake 
 sitehttp://book.cakephp.org/view/1077/An-Exampledont really speak to
 this.

 Does anyone know where I am going wrong?

 Thanks
 Steve

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Custom Datasource

2011-11-15 Thread RhythmicDevil
I got it working finally. This is what I ended up with:

database.php

public $gti = array(
'datasource' = 'GtiSource',
'url' = 'http://swright-dev:1337/'
);


Model

public $useDbConfig = 'gti';

Datasource
filename: GtiSource.php
class : GtiSource

Although the filename: gti_source also works.





-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: accessing a function in a custom datasource, from the model

2011-05-05 Thread dreamingmind
flowctrl,

I don't know about datasources specifically but I know generally about
your problem. Possibly this example will put you on the path.

I wanted to modify a behavior I had connected to some models, call it
niceBehavior. So my models had this:
var $actsAs = array('niceBehavior');

and my new class is called fixNiceBehavior. It is like your example:
Class fixNiceBehavior Extends NiceBehavior {
//methods here
}

If run things now, any functions in my new class will throw the errors
you describe. But if I change my models to read:
var $actsAs = array('fixNiceBehavior');

I'll have BOTH classes and their properties and methods available
through fixNiceBehavior. So, if niceBehavior-do_magic() was a method;
because fixNiceBehavior extends niceBehavior, fixNiceBehavior-
do_magic() is 'magically' available along with all my other newly
written properties and methods.

Other times, you'll have to break out the big guns to load your class.
App::import() will do that for you.
http://book.cakephp.org/view/1031/Saving-Your-Data#!/view/933/The-App-Class

Regards,
Don

On May 4, 4:21 pm, flowctrl flowc...@gmail.com wrote:
 Hello,

 In CakePHP 1.3, how do I use a function in a custom datasource, from a
 model that uses that datasource?

 My custom datasource works for regular queries, but I want to extend
 the default find method to include a new parameter. In app/models/
 datasources/foofiles_source.php I have a function to find video files
 on the filesystem. For testing, it is:

 class FoofilesSource extends DataSource {

public function find_videos($videoQuery) {
  return(array(This is in the foo_files datasource!,
 w00t!));
}
 …

 In the FooFiles model, I have:

function find($type, $options = array()) {
   switch($type) {
  case videos:
 $this-find_videos($options);
 break;

  default:
 return parent::find($type, $options);
 break;
   }
}

 However, $this-find_videos($options) produces a fatal error:
 Fatal error: Call to undefined method FoofilesSource::query() in cake/
 libs/model/model.php on line 502

 If I use FoofilesSource::find_videos($options) instead, I get the
 error:
 Fatal error: Class 'FooFilesSource' not found in app/models/
 foo_files.php on line 11

 How do I invoke a function in the datasource, from a model?

 Thanks!

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Custom datasource ignored

2011-05-04 Thread flowctrl
Thanks! That was it.

On Apr 30, 7:51 am, Tilen Majerle tilen.maje...@gmail.com wrote:
 cakephp is still looking for database, because you wrong type model
 property...it's $useTable not $useTables :) (so letter S at the end is
 problem ) :)
 --
 Lep pozdrav, Tilen Majerlehttp://majerle.eu

 2011/4/30 flowctrl flowc...@gmail.com



  Hello,

  CakePHP seems to be ignoring the $useDbConfig variable in my model.
  I'm trying to use a custom datasource, but I'm getting the error:

  Database table foo_files for model FooFiles was not found.

  When I first loaded the model and new datasource, there were typos in
  the datasource file which caused errors, so I know that the datasource
  file is actually being loaded. Why is CakePHP still looking for a
  database table?

  My model, app/models/foo_files.php, contains:

  class FooFiles extends AppModel {
         var $name = 'FooFiles';
         var $useTables      = false;
         var $useDbConfig = 'foofiles';
  }

  The app/config/database.php file has:

         var $foofiles = array(
                 'datasource' = 'foofiles',
                 'workshopsdir' = '/some/dir',
         );

  My new datasource, app/models/datasources/myfiles_source.php, contains
  (summarized):

  class FoofilesSource extends DataSource {

   protected $_schema = array(
         'files' = array( ... )
   );

   public function listSources() {
     return array('files');
   }

   public function describe($model) {
     return $this-_schema['files'];
   }

   public function read($model, $queryData = array()) {
         $workshopsDir = $config['workshopsdir'];
         if(!isset($queryData['conditions'])) $queryData['conditions'] =
  'all';

       $events = array();
         switch ($queryData['conditions']) {
                 default:
                 return(glob($workshopsDir/*));
                 break;

                 case $array[] = 'videos':
                         ...
                 }
   }

  Any advice would be appreciated!

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

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

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


accessing a function in a custom datasource, from the model

2011-05-04 Thread flowctrl
Hello,

In CakePHP 1.3, how do I use a function in a custom datasource, from a
model that uses that datasource?

My custom datasource works for regular queries, but I want to extend
the default find method to include a new parameter. In app/models/
datasources/foofiles_source.php I have a function to find video files
on the filesystem. For testing, it is:

class FoofilesSource extends DataSource {

   public function find_videos($videoQuery) {
 return(array(This is in the foo_files datasource!,
w00t!));
   }
…


In the FooFiles model, I have:

   function find($type, $options = array()) {
  switch($type) {
 case videos:
$this-find_videos($options);
break;

 default:
return parent::find($type, $options);
break;
  }
   }

However, $this-find_videos($options) produces a fatal error:
Fatal error: Call to undefined method FoofilesSource::query() in cake/
libs/model/model.php on line 502

If I use FoofilesSource::find_videos($options) instead, I get the
error:
Fatal error: Class 'FooFilesSource' not found in app/models/
foo_files.php on line 11

How do I invoke a function in the datasource, from a model?

Thanks!

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Custom datasource ignored

2011-04-30 Thread flowctrl
Hello,

CakePHP seems to be ignoring the $useDbConfig variable in my model.
I'm trying to use a custom datasource, but I'm getting the error:

Database table foo_files for model FooFiles was not found.

When I first loaded the model and new datasource, there were typos in
the datasource file which caused errors, so I know that the datasource
file is actually being loaded. Why is CakePHP still looking for a
database table?

My model, app/models/foo_files.php, contains:

class FooFiles extends AppModel {
var $name = 'FooFiles';
var $useTables  = false;
var $useDbConfig = 'foofiles';
}

The app/config/database.php file has:

var $foofiles = array(
'datasource' = 'foofiles',
'workshopsdir' = '/some/dir',
);


My new datasource, app/models/datasources/myfiles_source.php, contains
(summarized):

class FoofilesSource extends DataSource {

  protected $_schema = array(
'files' = array( ... )
  );

  public function listSources() {
return array('files');
  }

 public function describe($model) {
return $this-_schema['files'];
 }

 public function read($model, $queryData = array()) {
$workshopsDir = $config['workshopsdir'];
if(!isset($queryData['conditions'])) $queryData['conditions'] =
'all';

  $events = array();
switch ($queryData['conditions']) {
default:
return(glob($workshopsDir/*));
break;

case $array[] = 'videos':
...
}
 }


Any advice would be 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Custom datasource ignored

2011-04-30 Thread Tilen Majerle
cakephp is still looking for database, because you wrong type model
property...it's $useTable not $useTables :) (so letter S at the end is
problem ) :)
--
Lep pozdrav, Tilen Majerle
http://majerle.eu



2011/4/30 flowctrl flowc...@gmail.com

 Hello,

 CakePHP seems to be ignoring the $useDbConfig variable in my model.
 I'm trying to use a custom datasource, but I'm getting the error:

 Database table foo_files for model FooFiles was not found.

 When I first loaded the model and new datasource, there were typos in
 the datasource file which caused errors, so I know that the datasource
 file is actually being loaded. Why is CakePHP still looking for a
 database table?

 My model, app/models/foo_files.php, contains:

 class FooFiles extends AppModel {
var $name = 'FooFiles';
var $useTables  = false;
var $useDbConfig = 'foofiles';
 }

 The app/config/database.php file has:

var $foofiles = array(
'datasource' = 'foofiles',
'workshopsdir' = '/some/dir',
);


 My new datasource, app/models/datasources/myfiles_source.php, contains
 (summarized):

 class FoofilesSource extends DataSource {

  protected $_schema = array(
'files' = array( ... )
  );

  public function listSources() {
return array('files');
  }

  public function describe($model) {
return $this-_schema['files'];
  }

  public function read($model, $queryData = array()) {
$workshopsDir = $config['workshopsdir'];
if(!isset($queryData['conditions'])) $queryData['conditions'] =
 'all';

  $events = array();
switch ($queryData['conditions']) {
default:
return(glob($workshopsDir/*));
break;

case $array[] = 'videos':
...
}
  }


 Any advice would be 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+unsubscr...@googlegroups.com For more options, visit this group
 at http://groups.google.com/group/cake-php


-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Custom Datasource for INI files

2010-02-23 Thread john Lange
I'm trying to write a custom datasource that reads and writes INI
files (php ini files, not Windows). Even though INI files and
databases are fundamentally incompatible in many ways, I never the
less would like it to be as compatible with database sources as
possible.

I've created class IniSource extended from DataSource, but, being new
to Cake I'm not sure what functions I must implement in order to get
this working. Currently I'm getting the error:

Call to undefined method IniSource::fullTableName

but I think that might be because I'm not implementing the object
properly in the model rather than because of some problem with the
datasource itself.

If there are any tips or documentation on how implement this class it
would be appreciated.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en