Re: bake

2008-02-07 Thread Takuo SHIONO

Hello,

The code to deduce table relationship is in ModelTask::doAssociations() 
defined in /cake/console/libs/tasks/model.php
You also have to check Inflector class defined in 
/cake/libs/inflector.php. This define naming conventions.

I think this mechanism is based on the cakePHP naming convention and 
there is no template for this purpose. So you need modify the source 
code in order to customize bake behaviors.


Best Wishes,

Takuo Shiono

zeugme wrote:
> Sorry for reposting but I really would like to custimize bake 
> generation, if it is possible.
> Are there templates ? Same as scaffolding ?
> 
> Also, I need more info on table relationship taken into account in the 
> generated model.
> 
> Any clue appreciated, including pointer to the cake code
> 
> zeugme wrote:
>> Hi the list !
>>
>> Do you know if the bake generator is able to deduce table relationship 
>> when it generate the model ?
>> If it is possible, I suppose it need a DB strict name convention ... any 
>> info, doc, tuto, examples,
>>
>> Also, how to customize baked view, model, controller ? Any tips, 
>> example, recommendation ?
>> Where could I find documented all the "special variable" available ? 
>> (I'm guessing I'll need an array of the field in a view for example)
>>
>> Thanks !
>>
>>   
> 
> 
> > 


--~--~-~--~~~---~--~~
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: CakePHP guide

2008-02-07 Thread Takuo SHIONO

Hello Zoe,

Thank you for your great work.
I am using cakePHP reading the source code. So, Now I can use cakePHP as 
I want in many cases. However we need the guide for beginners, and I 
think your guide will be such guide.

By the way, I am Japanese. I think Japanese developers want to read 
documents in Japanese. So I want to translate your guide into Japanese. 
Can I do that?


Best Wishes,

Takuo Shiono

MonkeyGirl wrote:
> Hi!
> 
> Just to let you all know, I've finally written enough of the CakePHP
> guide that I'm working on to warrant putting it online at last. It's
> available here:
> 
> http://cakephp.bytenoise.co.uk/
> 
> It's only the first three chapters so far, but hopefully I should have
> a lot more there over the next few weeks.
> 
> Any comments and constructive criticism are both welcomed.
> 
> Thanks,
> Zoe.
> > 


--~--~-~--~~~---~--~~
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: Database design

2008-01-27 Thread Takuo SHIONO

Hello,

If you do not want to keep unnecessary fields for almost 50% of images, 
you can use image_link table, which contains 3 fields(image_id, next_id, 
previous_id). You maintain this table in afterSave function only when 
you edit or add valid images.

You can define the HASONE relationship between image model and 
image_link model. I think this makes your code smart like below:

// Controller
$image = $this->Image->findById($id);
$this->set('image', $image);

// View
link('next', '/images/view/'. 
$image['ImageLink']['next_index']); ?>


Best Wishes,

Takuo Shiono

Novice Programmer wrote:
> Hello Shiono,
> 
> When i tried to add the two fields, it seemed like an overhead to me because
> almost 50% of the images would be invalid, so adding two fields to database
> design will lead to addition of these fields in these invalid images as well
> and hence occupy more space in database. I want to avoid that if possible.
> 
> Thanks.
> 
> 
> On 1/27/08, Takuo SHIONO <[EMAIL PROTECTED]> wrote:
>>
>> Hello,
>>
>> I often use solution 1. I think this solution can be applied in almost
>> all cases. However I have another solution. How about this:
>>
>> 1. add 2 fields (prev_valid_index and next_valid_index) in table.
>> 2. update these fields in afterSave function.
>> 3. show image with the next/previous link according to the fields.
>>
>>
>> Best Wishes,
>>
>> Takuo Shiono
>>
>> Novice Programmer wrote:
>>> Though this is less of a database question. but i am still posting it
>> here
>>> since I think we can discuss the design as well.. :).
>>>
>>> I am maintaining a adresses of images stored on my filesystem in a
>> database.
>>> I have designed a system to show those images to the user. This
>> interface
>>> has the next and previous button as well. When user clicks on next he
>> goes
>>> to the *next valid image*. Note the difference here. I have to show only
>>> valid images. This means that all the images in the database are not to
>> be
>>> shown. Lets consider an example. Say that my database consists of
>> following
>>> images:
>>>
>>> 1. Image1(Valid)
>>> 2. Image2(InValid)
>>> 3 Image3(Invalid)
>>> 4. Image4(Valid)
>>>
>>> so when user is viewing image 1 and clicks on next he goes to image4
>>> directly even though image2 is stored in the next index on the database.
>> I
>>> have thought of following solutions but none of them are appealing me:
>>>
>>> 1. Maintain a variable which tells the index of next valid image.
>> Maintain a
>>> variable which tells me the index of last valid image and when next
>> valid
>>> image comes, update the index of the last valid image with this new
>> image.
>>> Similarly maintain the previous variable.
>>> 2. I am storing time stamp along with the images. On clicking next, I
>> load
>>> the image having the most recent time stamp after this image. but still
>> I
>>> dont like this query as this may be slow.
>>>
>>> Please help.
>>>
>>
> 
> 


--~--~-~--~~~---~--~~
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: Database design

2008-01-27 Thread Takuo SHIONO

Hello,

I often use solution 1. I think this solution can be applied in almost 
all cases. However I have another solution. How about this:

1. add 2 fields (prev_valid_index and next_valid_index) in table.
2. update these fields in afterSave function.
3. show image with the next/previous link according to the fields.


Best Wishes,

Takuo Shiono

Novice Programmer wrote:
> Though this is less of a database question. but i am still posting it here
> since I think we can discuss the design as well.. :).
> 
> I am maintaining a adresses of images stored on my filesystem in a database.
> I have designed a system to show those images to the user. This interface
> has the next and previous button as well. When user clicks on next he goes
> to the *next valid image*. Note the difference here. I have to show only
> valid images. This means that all the images in the database are not to be
> shown. Lets consider an example. Say that my database consists of following
> images:
> 
> 1. Image1(Valid)
> 2. Image2(InValid)
> 3 Image3(Invalid)
> 4. Image4(Valid)
> 
> so when user is viewing image 1 and clicks on next he goes to image4
> directly even though image2 is stored in the next index on the database. I
> have thought of following solutions but none of them are appealing me:
> 
> 1. Maintain a variable which tells the index of next valid image. Maintain a
> variable which tells me the index of last valid image and when next valid
> image comes, update the index of the last valid image with this new image.
> Similarly maintain the previous variable.
> 2. I am storing time stamp along with the images. On clicking next, I load
> the image having the most recent time stamp after this image. but still I
> dont like this query as this may be slow.
> 
> Please help.
> 


--~--~-~--~~~---~--~~
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: FPDF and FPDI with CakePHP

2008-01-18 Thread Takuo SHIONO

Hello Gianluca,

In may case, we put FPDF into vendors directory. Then we generate 
component php file, pdf_generator.php. In this php file, we define two 
classes. The first one is PdfGeneratorComponent class which is component 
class. The other is MyFPDF class which extends FPDF class.

The following is the brief example.

pdf_generator.php:


In the controller, we use this component as follows:

xxx_controller.php:
Pdf->generate();
 exit;
   }
}
?>


Best Wishes,

Takuo Shiono



--~--~-~--~~~---~--~~
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: mysql cache?

2008-01-16 Thread Takuo SHIONO

Hello,

Sorry, I cannot find the mistakes in your code.
try following:

1. move the line "$this->cacheQueries = false;" to the line before first 
select query.

2. check whether the update query was successed or not. check the value 
of curId in DB from mysql client(mysql command or phpMyAdmin...).

3. check the return value of "$this->execute($sql);"

Best Wishes,

Takuo Shiono


--~--~-~--~~~---~--~~
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: FPDF and FPDI with CakePHP

2008-01-15 Thread Takuo SHIONO

Hello Gianluca,

I am also using FPDF with cakePHP.

I think the problem is that the program output the white spaces in the 
layout template before FPDF outputs HTTP headers for pdf file.

Please try:
$this->layout = null;


If this does not work, there is another solution.
You do not need to use view.
You create a component for generating pdf.
(PdfComponent)

// app/controllers/components/pdf.php
class PdfComponent extends Object {
   function generate() {
 $pdf = new PdfGenerator();

 /// code for generating pdf

 $pdf->Output(); // This function output HTTP protocol headers.
   }
}

The controller use this component and do not use view.

TestController extends AppConteroller {
   var $components = array('Pdf');
   function generate() {
 $this->Pdf->generate();
 exit; // Do not show the content of view.
   }
}

This works fine for me.


Best Wishes,

Takuo Shiono

--~--~-~--~~~---~--~~
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: mysql cache?

2008-01-15 Thread Takuo SHIONO

Hi,

I think this is the effect of cache in Model class.
Please insert the line below before execute query. This disable cache 
functionalities in Model class.

$this->cacheQueries = false;

Best Wishes,

Takuo Shiono


[EMAIL PROTECTED] wrote:
> '$type = "ORD"
> $today = date("Ym");
> $sql = "select curType,curId from orders_sequence where
> curDate='$today' and type='$type'";
> $row_1 =  $this->findBySql($sql);
> 
> 
> $sql = "update  orders_sequence  set curId = curId + 1 where
> curDate='$today' and type='$type'";
> $this->execute($sql);
> 
> 
> 
> $sql = "select curType,curId from orders_sequence where
> curDate='$today' and type='$type'";
> $row_2 =  $this->findBySql($sql);
> 
> 
> $row1 == $row2 ? why ??  please help me,thanks
> 
> > 


--~--~-~--~~~---~--~~
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: mysql cache?

2008-01-15 Thread Takuo Shiono

Hi,

I think this is the effect of cache in Model class.
Please insert the line below before execute query. This disable cache
functionalities in Model class.

$this->cacheQueries = false;

Best Wishes,

Takuo Shiono

On Jan 15, 5:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> '$type = "ORD"
> $today = date("Ym");
> $sql = "select curType,curId from orders_sequence where
> curDate='$today' and type='$type'";
> $row_1 =  $this->findBySql($sql);
>
> $sql = "update  orders_sequence  set curId = curId + 1 where
> curDate='$today' and type='$type'";
> $this->execute($sql);
>
> $sql = "select curType,curId from orders_sequence where
> curDate='$today' and type='$type'";
> $row_2 =  $this->findBySql($sql);
>
> $row1 == $row2 ? why ??  please help me,thanks

--~--~-~--~~~---~--~~
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: $title_for_layout

2008-01-15 Thread Takuo SHIONO

Hi,

If you want to use $description_for_layout as same as $title_for_layout, 
you have to extends View class(cake/libs/view/view.php). You can find 
the mechanism of $title_for_layout in View::renderLayout().

However I do not want to modify the file in cake directory. I often 
extends AppController for this purpose.

1. copy cake/app_controller.php to app/app_controller.php
2. add a variable named $pageDescription in AppController
3. override beforeRender() and put the line below:

$this->set('description_for_layout', $this->pageDescription);


This works fine for me.

If you override beforeRender() in other controllers which extends 
AppController, do not forget call the AppController's beforeRender().


Best Wishes,

Takuo Shiono

vdvm wrote:
> Hi,
> 
> In a controller you can use $this->pageTitle wich corresponds with
> $title_for_layout in your layout.
> I would like to create $description_for_layout and use it as $this-
>> pageDescription in my controller.
> How can i create this?
> 
> Thank you!
> 
> > 


--~--~-~--~~~---~--~~
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: Can I use model class independently?

2007-11-30 Thread Takuo Shiono

> It's too tied into the framework itself to be used independently.  I
> suggest using something Propel (http://propel.phpdb.org/trac/) if you
> want to add ORM to an existing project.

Thank you for your advice.
I prefer to use cakePHP model as ORM since I am familiar with it.
It seems to be convinient for using other ORM as you suggested.


Best Wishes

Takuo Shiono

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



Can I use model class independently?

2007-11-29 Thread Takuo Shiono

Hi.

I am a new member of this group. So please forgive me if I do not know
the common view of this group.

Now I am trying to use cakePHP model classes independently.
I have to use our original framework which do not have OR mapping. I
am very happy if I can use cakePHP for OR mapping in the form of
something like library or module.

Currently I try to two approaches.
One way is as follows:

1. set up cake PHP and generate model.
2. create controller class for OR mapping
3. call the index.php of cakePHP from our framework after setting
QueryString corresponding to the OR mapping controller

I do not need modify the cakePHP code in this way. But I think It is
easy to encounter the problem around QueryString in our framework.


The other way is very simple.
I extract the code of model creation from controller.php and so on.
But this way is very complicated and can not follow the version up of
cakePHP.


Do you have any idea for using model independently?

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