Re: datasource and count()

2010-01-29 Thread fain182
2010/1/27 John Andersen j.andersen...@gmail.com:
 Ok, I would like to understand what is your issue here, because I do
 not see a calculate method in the DataSource class! Do you mean the
 DboSource?
   John

I tried to make a $this-Image-find('count'); on the model with my
datasource, and it gives error:
Fatal error: Call to undefined method FilewidSource::calculate() in
/home/fain182/workspace/cake/libs/model/model.php on line 2042

if you read the source of _findCount() you see that use calculate..
http://api.cakephp.org/view_source/model/#line-2040

maybe with a behaviour i could change this..
but it's a little dirty make a datasource that depends on behavior..

-- 
pietro

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


Re: datasource and count()

2010-01-29 Thread John Andersen
Ok, then it is not in the your DataSource class there is a need for
the calculate method, but in your generic filesystem class, to which
the DataSource refers to (through configuration).

As I understand, CakePHP use a DataSource to provide an implementation
independent interface to the DboSource (plus subclasses)
implementation dependent interface.

Thus your FilewidSource class (the implementation dependent interface)
should provide the calculate method.

Am I correct in my understanding of your issue?
Enjoy ;)
   John

On Jan 29, 11:17 am, fain182 fain...@gmail.com wrote:
 2010/1/27 John Andersen j.andersen...@gmail.com:

  Ok, I would like to understand what is your issue here, because I do
  not see a calculate method in the DataSource class! Do you mean the
  DboSource?
    John

 I tried to make a $this-Image-find('count'); on the model with my
 datasource, and it gives error:
 Fatal error: Call to undefined method FilewidSource::calculate() in
 /home/fain182/workspace/cake/libs/model/model.php on line 2042

 if you read the source of _findCount() you see that use 
 calculate..http://api.cakephp.org/view_source/model/#line-2040

 maybe with a behaviour i could change this..
 but it's a little dirty make a datasource that depends on behavior..

 --
 pietro

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


Re: datasource and count()

2010-01-27 Thread fain182
2010/1/26 John Andersen j.andersen...@gmail.com

 How do you search for your files that fulfill your criteria?

 If you are using a pattern, like *.txt, then you could just use the
 function glob(*.txt) to return the filenames and dirnames that
 comply with the pattern. The result is an array, which you can
 count :)

no, i need something more complex, and i want do it in the more cake-ish way
possible..

I have a model Image that use my datasource, and everything works, but if i
want to know the number of row that will return a find i must have code
like:
count( $this-Image-find('all', array('conditions'=...)) );

but it's a little bit dirty..
and i wanted to have something like:
$this-Image-find('count', array('conditions'=...))

but i didn't found documentation on how to implement something like this,
and reading the code, seems that find('count',...) is possible only for sql
based datasource..

 There is no need to worry about the reference to COUNT in MySql, that
 is only if you are using a database.

no, i want COUNT in a datasource that is not SQL..

-- 
pietro

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


Re: datasource and count()

2010-01-27 Thread John Andersen
Ok, I would like to understand what is your issue here, because I do
not see a calculate method in the DataSource class! Do you mean the
DboSource?
   John

On Jan 27, 5:52 pm, fain182 fain...@gmail.com wrote:
 2010/1/26 John Andersen j.andersen...@gmail.com

  How do you search for your files that fulfill your criteria?

  If you are using a pattern, like *.txt, then you could just use the
  function glob(*.txt) to return the filenames and dirnames that
  comply with the pattern. The result is an array, which you can
  count :)

 no, i need something more complex, and i want do it in the more cake-ish way
 possible..

 I have a model Image that use my datasource, and everything works, but if i
 want to know the number of row that will return a find i must have code
 like:
 count( $this-Image-find('all', array('conditions'=...)) );

 but it's a little bit dirty..
 and i wanted to have something like:
 $this-Image-find('count', array('conditions'=...))

 but i didn't found documentation on how to implement something like this,
 and reading the code, seems that find('count',...) is possible only for sql
 based datasource..

  There is no need to worry about the reference to COUNT in MySql, that
  is only if you are using a database.

 no, i want COUNT in a datasource that is not SQL..

 --
 pietro

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


Re: datasource and count()

2010-01-26 Thread fain182
no one ever tried to write a datasource with count included and not
for an SQL  database?

2010/1/21 fain182 fain...@gmail.com:
 Hello,
 I wrote a little datasource that i need to browse the filesystem..
 find('all'), find('first') works without any problem, but I tried to
 use find('count') and I discovered that I need to implement
 calculate() on my datasource..
 but calculate documentation says that Returns an SQL calculation,
 i.e. COUNT() or MAX() !?
 find(count) can be used only by SQL based datasource??

 or I am missing something?
 thank you

 PS: it would be cool add some information about this in the cookbook too..

 --
 pietro




-- 
pietro

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


Re: datasource and count()

2010-01-26 Thread John Andersen
How do you search for your files that fulfill your criteria?

If you are using a pattern, like *.txt, then you could just use the
function glob(*.txt) to return the filenames and dirnames that
comply with the pattern. The result is an array, which you can
count :)

There is no need to worry about the reference to COUNT in MySql, that
is only if you are using a database.

Enjoy,
   John

On Jan 26, 7:32 pm, fain182 fain...@gmail.com wrote:
 no one ever tried to write a datasource with count included and not
 for an SQL  database?

 2010/1/21 fain182 fain...@gmail.com:



  Hello,
  I wrote a little datasource that i need to browse the filesystem..
  find('all'), find('first') works without any problem, but I tried to
  use find('count') and I discovered that I need to implement
  calculate() on my datasource..
  but calculate documentation says that Returns an SQL calculation,
  i.e. COUNT() or MAX() !?
  find(count) can be used only by SQL based datasource??

  or I am missing something?
  thank you

  PS: it would be cool add some information about this in the cookbook too..

  --
  pietro

 --
 pietro

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


datasource and count()

2010-01-21 Thread fain182
Hello,
I wrote a little datasource that i need to browse the filesystem..
find('all'), find('first') works without any problem, but I tried to
use find('count') and I discovered that I need to implement
calculate() on my datasource..
but calculate documentation says that Returns an SQL calculation,
i.e. COUNT() or MAX() !?
find(count) can be used only by SQL based datasource??

or I am missing something?
thank you

PS: it would be cool add some information about this in the cookbook too..

-- 
pietro
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