Re: Save doesn't work with Postgres

2007-12-01 Thread Adrian Maier

On Nov 30, 2007 12:01 PM, Rhee <[EMAIL PROTECTED]> wrote:
>
> No one has ever this problem?
>
>
> On Nov 29, 12:17 pm, Rhee <[EMAIL PROTECTED]> wrote:
> > Does anybody have problem to use Save function with Postgres?
> > Everytime I call $this->Model->save($this->data) I get the following
> > notice messages (repeated 4 times):
> >
> > Notice: Undefined index: name in /var/www/htdocs/sid/cake/libs/model/
> > dbo/dbo_postgres.php on line 350
> >
> > and then:
> > Warning: Cannot modify header information - headers already sent by
> > (output started at /var/www/htdocs/sid/cake/libs/model/dbo/
> > dbo_postgres.php:350) in /var/www/htdocs/sid/cake/libs/controller/
> > controller.php on line 447
> >
> > Basically the data were saved into database.
> >
> > It works well at production level. I believe in this level all notices
> > and warnings were suppressed, so it looks like to work perfectly.
> > Right now, to avoid the notices I use $this->Model->execute($sql);
> > where $sql is an SQL INSERT INTO or UPDATE statement.
> >
> > I still use Cake v 0.2.9.4409. The same version works well with MySQL.
> >
> > Any idea to resolve this, except with execute() or maybe upgrade Cake?

Hello,

I've encountered the same error when using a PostgreSQL database.  It's a
bug that has been very recently solved .

Instead of upgrading, i've simply duplicated the fix on the version of cakephp
i was using . The fix is a trivial one:   open the dbo_postgres.php  ,
go to line 350
and modify this "if" statement :

 if (strcasecmp($sourceinfo['name'], $field) == 0) {
break;
 }

to this :

 if (  isset($sourceinfo['name']) &&
strcasecmp($sourceinfo['name'], $field) == 0)   {
break;
 }

You could also try to upgrade to a newer cake , but i'm not sure which
is the first version
that includes this particular bug fix.


Cheers,
Adrian Maier

--~--~-~--~~~---~--~~
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: HtmlHelper->input vs FormHelper->input

2007-03-27 Thread Adrian Maier

On 3/27/07, djiize <[EMAIL PROTECTED]> wrote:
>
> Hello
>
> Html helper is the old way, and Form helper the ne cutting-edge one
> (and I like it a lot ;))
>
> To get rid of div and label, you can write
> $this->input('tagname', array('div' => false, 'label' => false));

Thanks for sharing this information.
It's amazing to see how easy it is to control this behavior !

> If you plan to use Cake 1.2, I don't think it's a good idea to
> continue with html helper.

Yes, i'm using 1.2 even if it's not 'stable' yet because it has the
PaginatorHelper and some fixes related to inflections.

> Maybe it'll be remove in 2.0, but I prefer taking the new habit ASAP

My understanding is that only the form-related methods of HtmlHelper
will be deprecated. I think that the methods like link(), image() will
remain there.


Thanks !

Adrian Maier

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



HtmlHelper->input vs FormHelper->input

2007-03-26 Thread Adrian Maier

Hello,

I am a little confused about about why both HtmlHelper and FormHelper
have an input() method.

It looks like the

I am reluctant to use the HtmlHelper because :
- i saw in the archives that the plan is to deprecate the common methods
in favour of FormHelper
- (if i remember correctly) i've encountered a difference in behaviour between
HtmlHelper->select() and FormHelper->select()  .

However,  FormHelper->input() automatically creates a div around it and puts
the label automatically.  It's not clear how to get rid of both the div and the
label .

Should i use HtmlHelper->input()  instead or should i alter the css so
that the div
looks smaller or invisible  ?


-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: Page not refreshed after $this->redirect

2007-03-12 Thread Adrian Maier

On 3/12/07, Chris Lamb <[EMAIL PROTECTED]> wrote:
> "Adrian Maier" <[EMAIL PROTECTED]> wrote:
>
> > The problem is that the page is not refreshed, and the deleted record
> > is still visible until i  click the browser's "Refresh" button.
>
> This[0] is probably what you want.

Thanks for the link,  Chris.  I'll try to investigate in the direction
described in that thread.

The interesting part is that you are suspecting that the cause of
my problem is related to cake's caching,while i was suspecting
that it's external to cake : in apache's or php's config.

Cheers,
Adrian Maier

--~--~-~--~~~---~--~~
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: New Cake FAQ

2007-03-11 Thread Adrian Maier

On 3/10/07, Sam Sherlock <[EMAIL PROTECTED]> wrote:
> > 1: Make a Hello World Application.
>
> Yep and perhaps the  title should be
>
> "We knew you were coming so we baked a cake!"

Such titles could be misleading for a beginner , in my opinion  :)

Perhaps the FAQ could include these questions as well :

Q: What is a "baker"  ?
Q: In the context of CakePHP, what's the meaning of the verb "to bake" ?


Cheers,
Adrian Maier

--~--~-~--~~~---~--~~
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: Fetching rows one by one

2007-03-09 Thread Adrian Maier

On 3/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> As ad7six said, this should be handled in your db if at all possible.

I guess that's what the two of you are thinking when you say "handle inside
the db"  are stored procedures, right?  It's not possible because the database
is  MySql...

> Assuming thats not possible, use limit and page arguments to work on a
> small subset of the data at one time.  First execute a count to find
> out how many records your dealing with, then loop through each subset.
> Something like this:
>
> $count = findCount($conditions);
> $page = 0;
> $limit=20; //set limit to any size, even 1
>//this is how many records you will have in memory at
> any given time.
>
> while(($page*$limit) < $count){
> $page++;
> $recs = findAll($conditions, $fields, $order, $limit, $page,
> $recursive);
> //now use a function call ror foreach to process your records
> }

Thanks.

I am perfectly clarified :  it is not possible to do exactly how i
hoped  ,  therefore i'll need to use a workaround.


Thanks you all,
Adrian Maier

--~--~-~--~~~---~--~~
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: Fetching rows one by one

2007-03-09 Thread Adrian Maier

On 3/9/07, Sergei <[EMAIL PROTECTED]> wrote:
>
> cant you just try it?
>
> -1 will fetch ONLY the fields of current model table, without any
> associated data.

Oh, I understand what you mean.   We are speaking of
different things :  you are telling me how to get no data at all.
While I want all the data , but in small chunks. Not all data
at once.


-- 
Adrian Maier

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



Page not refreshed after $this->redirect

2007-03-09 Thread Adrian Maier

Hello again,

When installing my application on a server  I have problems with
pages that are not refreshed after $this->redirect().

For example: a page displays several records, and each has a "Delete"
link.  The delete action deletes the records and then should re-generate
the page: $this->redirect(array('action'=>'index'), null, true);

The problem is that the page is not refreshed, and the deleted record is
still visible until i  click the browser's "Refresh" button.

This is happens only on my server (NetBSD, apache 2.0.55, php 5.2)
and it works on my workstation (Mandriva Linux, apache 2.2.3, php 4.4.4).

It's probably a configuration problem, but i have no idea where
to start investigating the problem.  Did anyone stumble across
similar problems ?



Thanks,
Adrian Maier

--~--~-~--~~~---~--~~
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: Fetching rows one by one

2007-03-09 Thread Adrian Maier

On 3/9/07, phirschybar <[EMAIL PROTECTED]> wrote:
>
> findAll($conditions = null, $fields = null, $order = null, $limit =
> null, $page = 1, $recursive = null);
>
> You can specify the fields you want to return, along with conditions,
> limits, just like any basic query.

I am aware that i can select only some of the fields

My issue is that find / findAll :
- reads all the matching the records from the table
- stores all the values in memory
- returns a reference to that array
Let's exaggerate and assume that there are 20 million tuples in
the table:  findAll will create an array with 20 million elements , even
if i specify only 2 of the table's fields .

I'd like to :
- issue a query
- while (are records left in the query result) : get next record  and process it

In this case only the array containing the current record would be generated,
therefore I could process millions of records without needing them stored
in memory.



-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: Fetching rows one by one

2007-03-09 Thread Adrian Maier

On 3/9/07, phirschybar <[EMAIL PROTECTED]> wrote:
>
> Take a look at this article:
> http://www.thinkingphp.org/2007/02/24/cake-12s-set-class-eats-arrays-for-breakfast/
>
> Dealing with big fat arrays in Cake can be a struggle at first but
> using the Set::extract method can pull out a set of the data you need
> very elegantly. See how Felix also uses array_combine to get just a
> nice set of key/value pairs out a deeply nested array?

Thanks for the link.
However it seems to me that the article is dealing with another issue :
this Set is another method of traversing an array and getting only some values
from that tree.  But it still requires you to do a $users =
$this->User->findAll().

My issue is that i want to avoid the creation of that tree of arrays ,
in order to
reduce the memory footprint.

> Anyways I would use extract to get the data you need from Table 1 and
> then loop over the array and do your UPDATE queries on your second
> table.


It looks like indeed it's not possible to fetch records the way i'd like. If i
get into memory limitations  i'll just increase php's limit ...


Cheers,
Adrian Maier

--~--~-~--~~~---~--~~
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: Fetching rows one by one

2007-03-09 Thread Adrian Maier
On 3/9/07, Sergei <[EMAIL PROTECTED]> wrote:
>
> put
>
> $this->Model->recursive=-1;
>
> before your ->find query.

-1 doesn't appear in the manual amongst the possible values of $recursive.
What does it do exactly ?


> On 9 мар, 17:20, "Adrian Maier" <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > The Model->find  method builds a big array that contains all the tuples. Is
> > it possible to fetch the records one by one , in order to avoid that big 
> > array
> > to be constructed ?
>
>
> >
>


-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: Fetching rows one by one

2007-03-09 Thread Adrian Maier

On 3/9/07, AD7six <[EMAIL PROTECTED]> wrote:
>
> > Are there better ways to fetch the query result one by one  ?
>
> Why do you want to, what is the goal you want to achieve?

In short: I'm reading the tuples from table T1, and for each tuple i'm
searching for corresponding tuple in table T2 and , if neccessary, update
some fields of T2 according to the current tuple of T1.

Sometimes, if there are enough records in T1, my action reaches
PHP's maximum memory limit.  I haven't researched to see exactly
what is the number of records when the memory gets filled (but was
less than 15000 records).

What i want is to fetch the query results one by one, because in this
case i really don't need the array with all the records.


-- 
Adrian Maier

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



Fetching rows one by one

2007-03-09 Thread Adrian Maier

Hello,

The Model->find  method builds a big array that contains all the tuples. Is
it possible to fetch the records one by one , in order to avoid that big array
to be constructed ?

One possible way would be to : get the list of id's , and then traverse it
and use read($id)  to get only the current row.  This implies a select to be
called for each row, though . So this approach could be slow.

Are there better ways to fetch the query result one by one  ?


Cheers,
Adrian Maier

--~--~-~--~~~---~--~~
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: New Cake FAQ

2007-03-08 Thread Adrian Maier

On 3/8/07, nate <[EMAIL PROTECTED]> wrote:
>
> Wow, uh, okay, I guess I'll take everyone's enthusastic silence to
> mean that our documentation is perfect, no one has any questions, and
> we can just go ahead and close this mailing list, since everybody
> seems to know everything.  That's amazing.
>
> However, if anyone (and yes, *you* are included in 'anyone') happens
> to have a great, good, decent, or, hell, even a crappy, retarded
> question, please don't hesitate to attach it to the ticket linked
> above, with or without an answer.

Here are a few questions. (i find it much easier to put them here
than on trac...)

Q: Is it possible to use CakePHP with databases that don't follow
Cake's conventions (legacy databases or non-English table names) ?
A: Yes.  You can set the model's corresponding table with $useTable='my_table'
if the table name is not the plural of the model name or it is a
non-English word.
If the primary key is not called 'id' , you can set it to something else with
$primaryKey = 'pk_column'.

Q: What should I do when I'm stuck and the manual says nothing about
my problem?
A: (1) Search in the google group archives:
http://groups.google.com/group/cake-php
(2) Check the Bakery:  http://bakery.cakephp.org/
(3) Search the web with your favourite search engine
(4) Ask your question on the irc channel or on the google group.

Q: How can I paginate the query results in Cake?
A: (please correct me if my understanding about this is wrong...)
CakePHP 1.2.x.x introduced the PaginatorHelper , which eases this task.
(this feature will clearly deserve a place in the 1.2.x.x Manual as
well , in my opinion).
For CakePHP 1.1.x.x i think there was an article in the Bakery, but i
can't find
its link, sorry.

Q: How can I report a bug?
A: Please check this page https://trac.cakephp.org/wiki/bugreport



-- 
Adrian Maier

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



Strange error

2007-03-08 Thread Adrian Maier

Hello,

I have the following code :

$criteria =  array('cod_produs'=>$tuple['ImportData']['cod_produs'],
'furnizor'=>$tuple['ImportData']['furnizor']
);
if ($this->SupplierPrice->hasAny($criteria)) {
 $vechi = $this->SupplierPrice->find($criteria);
}

The code works well,  except for the cases when the field  'cod_produs'
contains the character dash '-'   (for example  cod_produs = 'KL(S)-23MU' ) .
 In this case the following error appears at the top of the page:

Query: SELECT COUNT(*) AS count FROM `supplier_prices` AS
`SupplierPrice` WHERE (`cod_produs` KL(S) '-23MU') AND (`furnizor` =
'ALINE')
Warning: SQL Error: 1064: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'KL(S) '-23MU') AND (`furnizor` = 'ALINE')' at line
1 in 
/home/am/sites/sigmanet/sigma_new_admin/cake/libs/model/datasources/dbo_source.php
on line 470


Normally, the generated query should have contained :
WHERE (`cod_produs`  =  'KL(S)-23MU' )
instead of
WHERE (`cod_produs` KL(S) '-23MU')

Does anyone happen know why a dash inside the value of the search criteria
could cause this incorrect query to be generated ?


-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: So confused

2007-03-05 Thread Adrian Maier

Hello,

I'd like to share my opinioin about CakePHP's documentation, from a newbie's
point of view. In short,  i dont' find bad or unusable :
- the Manual is ok .  Skimming throught it and following the tutorial
gave me some
  basic knowledge about how cake works. And, more importantly, convinced
  me that CakePHP is a good path to follow.
- i missed the ability to download the manual as a single zip file ,
for studying
  it offline.
- the API is helpful, but sometimes the parameters of the methods are explained
  in a minimalistic way. This is probably because the api is generated from the
  sources. The good  part is that there are links to the php code, so
it's possible
  to browse the code trying to see how does it work.

For example, please try to imagine for a minute that you are a beginner and you
come across the description of the method :
[api : 
http://api.cakephp.org/1.2/classModel.html#6b1a38f7a8ddb61cfa8539734b4d6430
]
Model::bindModel ($params, $reset = true)

Bind model associations on the fly.
If $reset is false, association will not be reset to the originals
defined in the model
[/api]

The $params argument is not explained , except that "it's an array".
It's not exactly
obvious what can be put into that array...

So, it would be very good to have a verbose API ,  with more detailed
descriptions
and maybe even some examples.  But i realize that it would take a lot of work to
add details to all those comments at the beginning of the methods , an activity
that is probably not the most exciting thing to do ...


Other sources on information :
- the irc : it's real-time,  but disorganized .  I find it difficult
to follow several
   different conversations taking place at the same time.
- the google group : very nice. I wish i had realised it's existance
sooner. I like it
   much more than the irc channel, because I have the time to compose the
   question or answer.  And it has the searchable archives ;-)


In conclusion,  the idea that "the documentation sucks" is innacurate and not
helpful .


-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: Inflections problem?

2007-03-04 Thread Adrian Maier

On 3/2/07, Petry <[EMAIL PROTECTED]> wrote:
>
> Hi people,
>
> I'm a brazilian developer an I have a problem with singular and plural
> rules:
>
> The word "Noticia" the plural form is "Noticias" (words ending by
> "ia", the plural form is "ias")
> The word "Album" the plural form is "Albuns" (words ending by "m", the
> plural form is "ns")
>
> Well for these cases, I've create in inflections.php two rules:
>
> $pluralRules = array('/(.*)m$/i' => '\1ns', '/(.*)ia$/i' => '\1ias');
>
> $singularRules = array('/(.*)ns$/i' => '\1m','/(.*)ias$/i' => '\1a');
>
> but when I create the MVC files with bake, for the word "Noticia",
> bake writes "Noticium"
>
> Why can i fix this problem?

I think that, apart from the rules that you specify,  there are also some
default rules.For example,  i've noticed that  'data' is turned
into 'datum' ,
which is very similar to what happens to your 'noticia'-->'noticium'.
I might be mistaken (becuse i'm a newbie and have very little understanding
on the CakePHP internals) but : probably the inflector is using the first rule
it finds , and for 'noticia' it happens to apply some default rule
instead of the
one that you've specified.

Have you tried to add to irregularPlurals 'noticia'=>'noticias' ?   The words
defined this way are supposed to bypass the rules.


-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: INSERT into databases

2007-03-04 Thread Adrian Maier

On 3/2/07, Chris Hartjes <[EMAIL PROTECTED]> wrote:
>
> On 2/27/07, Felix St. Bernard <[EMAIL PROTECTED]> wrote:
> > That was enough said Don't you think? I understand how queries like
> > his may "upset" you but keep your frustrations to yourself. You could
> > have also just made reference to the recent post "CakePHP IRC and
> > GoogleGroup Etiquette Suggestions" which may help this newby not repeat
> > what he just did. And that would be a whole lot less rude on your part.
> > If you can't do that then save yourself some typing time and just not
> > reply. Everyone has to start somewhere. Have a nice day.
> >
> > FSB
>
> I guess you could've saved yourself some typing time as well and not
> replied to me either, eh Felix? The younger version of me would've
> taken great offense at you've said, telling me I don't have a right to
> be frustrated and to not express myself.  After all, you're expressing
> your frustrations and opinions.  I'd like to think I'm allowed to do
> the same.
>
> Anyway, here's my point:  rude dickheads like myself are needed on a
> mailing list such as this one to remind people that there are certain
> rules to be followed, and one of those are to not expect people giving
> up their own free time (unless there are some very lucky people on
> this list who get paid to work on CakePHP) to provide with all the
> answers so you can just cut-and-paste without learning anything.  I'm
> 100% positive I'm not the only one on this mailing list who feels this
> way, I'm just one of the few who actually says it out loud...er on the
> mailing list.
>
> I'm all for helping people who are at least TRYING to learn something.
> Asking such a broad-based question as the one that started this
> thread means the person hasn't even bothered to do a shred of
> research.
>
> So, Mani, I highly suggest you search through the manual, look at the
> blog tutorial, and search the google groups archive for this mailing
> list.  If the answer isn't in there, then I'm sure someone (hey, it
> might even be me) will be more than happy to answer your question.
> I'm not such a bad guy, honest.
>
> Give someone code, they learn nothing.  Teach them why their code
> isn't working and they'll learn something.

It is true that Mani's question was probably a frequent one, and that the
answer can be found in the "Models" chapter of the CakePHP manual.

But, sorry Chrys , your initial reaction was too harsh. I read this
thread again
and I am not convinced at all that Mani really meant that others should
"write code for him , for free" .


-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: Question about pagination

2007-02-27 Thread Adrian Maier

On 2/27/07, nate <[EMAIL PROTECTED]> wrote:
>
> $scope is filtering criteria, and $whitelist is a list of allowed
> parameters.

Thanks for trying to explain, Nate. However, since i'm very new to
CakePHP   i can't figure out what would be the purpose of these
"allowed parameters".   :-D

> $object is interpreted as $scope if it is an array, since by default,
> the $object parameter is not required.

So,  the filter criteria should normally be passed as the $scope. In
this case what is $object meant for ?


I find that the API documentation is too minimal (it seems to be
generated from sources and sometimes the explainations are
not verbose enough).
But this is compensated by the people on this group who are very
nice and willing help.  :)

I'm very happy that i found this google group to post my questions : it's
easier to get answers here than on the irc channel where sometimes there
are several conversations taking place at the same time and it's hard
to follow,


Thanks,
Adrian Maier


> On Feb 27, 2:28 am, "Adrian Maier" <[EMAIL PROTECTED]> wrote:
> > On 2/27/07, Grant Cox <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Just pass your conditions as the first parameter to your paginate
> > > function.
> >
> > > $your_conditions = array('session_id'=>$session_id);
> > > $this->set( 'importData', $this->paginate($your_conditions) );
> >
> > Thanks,   I'll try this.
> >
> > The funny thing is that I had looked at the paginate() function in
> > the API, but I couldn't figure out by myself what is the meaning
> > of its parameters:
> > mixed   $object
> > mixed   $scope
> > array$whitelist
> >
> > I am wondering how is someone supposed to guess that the $object
> > is actually an array that defines the filtering criteria for the query.
> >
> > The other two parameters : $scope and $whitelist are still puzzling
> > me. What are they?

--~--~-~--~~~---~--~~
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: Model::save() and multicolumn primary key?

2007-02-27 Thread Adrian Maier

On 2/27/07, AD7six <[EMAIL PROTECTED]> wrote:
>
> On Feb 27, 11:36 am, "Adrian Maier" <[EMAIL PROTECTED]> wrote:
> > On 2/27/07, AD7six <[EMAIL PROTECTED]> wrote:
> >
> > > On Feb 27, 8:42 am, "Adrian Maier" <[EMAIL PROTECTED]> wrote:
> > > > On 2/27/07, Langdon Stevenson <[EMAIL PROTECTED]> wrote:
> >
> > > > > My understanding is that Cake 1.1.x.x doesn't support multi-column 
> > > > > keys.
> >
> > > > > This feature request in track:https://trac.cakephp.org/ticket/1293
> > > > > indicates that the priority for this feature is very low and unlikely 
> > > > > to
> > > > > be implemented.
> >
> > > > > Are you working with a legacy database?  Or is this your preferred way
> > > > > of building the primary key?
> >
> > > > Is this still true for Cake 1.2.x.x ?
> >
> > > > You might find this article interesting. It is about surrogate primary
> > > > key ( 'id' - integer )
> > > > which are sometimes convenient (from a performance point of view) but
> > > > are in fact
> > > > an evil compromise because such a primary key *does* allow row 
> > > > duplicates :
> >
> > > Does it? I always thought not including a unique index on a table's
> > > data allowed duplicates.
> >
> > It looks like we agree ...duplicates are possible if you rely solely on 
> > the
> > surrogate id and you don't add an unique index to enforce the real primary
> > key.
> >
> > In fact , a table frequently will have are two primary keys:
> > - the surrogate one (numeric,  or fast update/delete)
> > - the real one , which uniquely identifies a row based on the entity's
> >   properties ( a person's social number,  a book's  ISBN, etc ).
> > Since the primary key can be only one, people will normally define
> > the id as "primary key" and an "unique index" for the real key .
> >
> > But primary key and "unique index" is basically the same thing : the 
> > difference
> > is that a table can have only one primary key , while the unique indexes
> > can be more than one. "primary key" is just syntactic sugar for "unique and
> > not null" .
> >
> > > And I feel that's all the article proves. The PK is for identifying a
> > > row of data, a unique index is for preventing duplicates. There are
> > > times when the two can be one and the same, but in most cases they
> > > should not - if only because choosing something that seems to be
> > > unique which turns out not to be, or in some cases is null, is so
> > > difficult to rectify (quickly).
> > > What does this mean (extract from comments by the article author
> > > regarding one of the examples of why surrogate keys are bad):
> > > "You're correct, though, that because of the size of the key (three
> > > columns, one of them up to 100 chars of text) the table carried an
> > > INT4 surrogate key which is what we used for joins and application
> > > logic"
> >
> > At work we are writing some modules for a mass billing application (for
> > a telephony company) that uses a large database (oracle). For example
> > the account_number is a varchar(20)  and is heavily used as primary key
> > and foreign key. The performance is a serious consideration and yet they
> > have chosen to have varchar PKs  when their saw fit.
> >
> > So, i don't think that using other types of PKs is a noticeable penalty
> > for small and medium databases .
>
> Well, the type isn't really a factor, although a numerical field will
> sort faster than an alphanumerical field - the difference is rather
> small if you are comparing indexing a field of x characters versus a
> field of ~x digits.
>
> In the above example the account number makes a perfect logical
> primary key - the row can't exist without one and it absolutely must
> not be null. That 'cost' would pay dividends as soon as you did not
> need to query the database, or JOIN the account table in, to find the
> (otherwise not known) account number from an object that linked to
> it.
>
> However, If you have no logical primary key, a numerical auto-index is
> the best idea in most cases unless there is a reason not to. E.g. the
> large system I used ot work with used a base64 sequence for almost all
> tables to keep key lengths below 7 characters iirc (yes, some truel

Re: Model::save() and multicolumn primary key?

2007-02-27 Thread Adrian Maier

On 2/27/07, AD7six <[EMAIL PROTECTED]> wrote:
>
> On Feb 27, 8:42 am, "Adrian Maier" <[EMAIL PROTECTED]> wrote:
> > On 2/27/07, Langdon Stevenson <[EMAIL PROTECTED]> wrote:
> >
> > > My understanding is that Cake 1.1.x.x doesn't support multi-column keys.
> >
> > > This feature request in track:https://trac.cakephp.org/ticket/1293
> > > indicates that the priority for this feature is very low and unlikely to
> > > be implemented.
> >
> > > Are you working with a legacy database?  Or is this your preferred way
> > > of building the primary key?
> >
> > Is this still true for Cake 1.2.x.x ?
> >
> > You might find this article interesting. It is about surrogate primary
> > key ( 'id' - integer )
> > which are sometimes convenient (from a performance point of view) but
> > are in fact
> > an evil compromise because such a primary key *does* allow row duplicates :
>
> Does it? I always thought not including a unique index on a table's
> data allowed duplicates.

It looks like we agree ...duplicates are possible if you rely solely on the
surrogate id and you don't add an unique index to enforce the real primary
key.

In fact , a table frequently will have are two primary keys:
- the surrogate one (numeric,  or fast update/delete)
- the real one , which uniquely identifies a row based on the entity's
  properties ( a person's social number,  a book's  ISBN, etc ).
Since the primary key can be only one, people will normally define
the id as "primary key" and an "unique index" for the real key .

But primary key and "unique index" is basically the same thing : the difference
is that a table can have only one primary key , while the unique indexes
can be more than one. "primary key" is just syntactic sugar for "unique and
not null" .

> And I feel that's all the article proves. The PK is for identifying a
> row of data, a unique index is for preventing duplicates. There are
> times when the two can be one and the same, but in most cases they
> should not - if only because choosing something that seems to be
> unique which turns out not to be, or in some cases is null, is so
> difficult to rectify (quickly).

> What does this mean (extract from comments by the article author
> regarding one of the examples of why surrogate keys are bad):
> "You're correct, though, that because of the size of the key (three
> columns, one of them up to 100 chars of text) the table carried an
> INT4 surrogate key which is what we used for joins and application
> logic"

At work we are writing some modules for a mass billing application (for
a telephony company) that uses a large database (oracle). For example
the account_number is a varchar(20)  and is heavily used as primary key
and foreign key. The performance is a serious consideration and yet they
have chosen to have varchar PKs  when their saw fit.

So, i don't think that using other types of PKs is a noticeable penalty
for small and medium databases .

> My take is "the table had a normal PK", and kind of reinforces /why/ a
> numeric unique id field is used and useful as a prmiary key, and /why/
> a unique index on a table's data doesn't and shouldn't serve the same
> purpose.
>
> All IMO of course :),

;-)


Best wishes,

Adrian Maier

--~--~-~--~~~---~--~~
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: Model::save() and multicolumn primary key?

2007-02-26 Thread Adrian Maier

On 2/27/07, Langdon Stevenson <[EMAIL PROTECTED]> wrote:
>
> My understanding is that Cake 1.1.x.x doesn't support multi-column keys.
>
> This feature request in track: https://trac.cakephp.org/ticket/1293
> indicates that the priority for this feature is very low and unlikely to
> be implemented.
>
> Are you working with a legacy database?  Or is this your preferred way
> of building the primary key?

Is this still true for Cake 1.2.x.x ?

You might find this article interesting. It is about surrogate primary
key ( 'id' - integer )
which are sometimes convenient (from a performance point of view) but
are in fact
an evil compromise because such a primary key *does* allow row duplicates :

http://blogs.ittoolbox.com/database/soup/archives/primary-keyvil-part-i-7327?rss=1


Chers,
Adrian Maier

--~--~-~--~~~---~--~~
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: Question about pagination

2007-02-26 Thread Adrian Maier

On 2/27/07, Grant Cox <[EMAIL PROTECTED]> wrote:
>
> Just pass your conditions as the first parameter to your paginate
> function.
>
> $your_conditions = array('session_id'=>$session_id);
> $this->set( 'importData', $this->paginate($your_conditions) );

Thanks,   I'll try this.

The funny thing is that I had looked at the paginate() function in
the API, but I couldn't figure out by myself what is the meaning
of its parameters:
mixed   $object
mixed   $scope
array$whitelist

I am wondering how is someone supposed to guess that the $object
is actually an array that defines the filtering criteria for the query.

The other two parameters : $scope and $whitelist are still puzzling
me. What are they?


-- 
Adrian Maier

--~--~-~--~~~---~--~~
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: how to pass criteria to pagination object?

2007-02-26 Thread Adrian Maier

On 2/26/07, NOSLOW <[EMAIL PROTECTED]> wrote:
>
> This thread may be of use:
>
http://groups.google.com/group/cake-php/browse_thread/thread/5d0a4cb93d66a6c2/1d4d9e3a35ddfa47?hl=en#1d4d9e3a35ddfa47
>

It was indeed helpful. Thanks.

I have made the following changes :
- in the controller :
function index($session_id = null) {
$this->ImportData->recursive = 0;
$this->paginate['conditions']=array('session_id'=>$session_id);
$this->set('importData', $this->paginate());
$this->set('param_session_id', $session_id);
}

- in the view :
$paginator->prev('<< previous', array('url'=>$param_session_id), null,
array('class'=>'disabled'));
$paginator->next('next >>', array('url'=>$param_session_id), null,
array('class'=>'disabled'));
$paginator->sort('session_id',null,array('url'=>$param_session_id));?>


Cheers,
Adrian Maier

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