Re: relacionamento de tabelas

2008-01-01 Thread Juan Basso

Brasileiro é tudo igual... sempre querendo economizar onde pode, até
nas tabelas de relacionamento hehe.

Brincadeira, mas é isso mesmo que o Gustavo falou. Não deixou dúvidas.


Abraços e bom ano novo a todos.


Juan Basso

On 31 dez 2007, 11:11, Gustavo Carreno [EMAIL PROTECTED]
wrote:
 On Dec 30, 2007 2:33 PM, Bill [EMAIL PROTECTED] wrote:



  Olá Gustavo,

  Muito obrigado pela explicação, consegui entender sim.

 Optimo, eu proprio tive de reler a minha explicação para ver se fazia
 sentido, LOL!

  neste blog terei 3 tabelas a principio, posts, categorias e comentarios.

  Para o relacionamento entre psots X comentarios, poderei usar o
  relacionamento 1:n normal, agora, para o relacionamento posts X categorias,
  farei o que vc falou, irei usar uma terceira tabela categorias_posts, para
  fazer o relacionamento n:n

  Valeu, mto obrigado pela ajuda.
  Grande abraço

 De nada, se deu pra ajudar já me sinto feliz.
 Outro abraço e Feliz Ano Novo.







   On Dec 30, 2007 2:54 AM, Bill wrote:

   Olá galera,

   to montando um blog pro meu site, e não manjo nada de modelagem
   de dados.

   Tentei usar o DBDesigner pra montar as tabelas e relacionamentos
   mas não tive mto sucesso.
   Gostaria de saber se alguém pode dar um help com algo simples, de
   como montar 2 tabelinhas e relacioná-las, usando relacionamento
   de muitos para muitos.

   No caso, meu blog tem 2 tabelas, a de posts(id, categoria_id,
   titulo, texto), e a de categorias(id, nome).
   Pelo que entendi, o relacionamento tem q ser n:n, pois um post
   tem muitas categorias, e uma categoria tem muitos posts.

   Não quero relacionar como no screencast do tulio, usando uma
   terceira tabela categorias_posts, queria relacionar usando FK.

   Alguém pode me dar um help.

   Que eu saiba a unica maneira de fazer um relacionamento de N para N
   é mesmo só com uma terceira tabela.
   Um relacionamento de N para N é feito associando dois ID's, um de
   cada tabela. Se fosse só um ID de uma tabela, como num
   relacionamento N para 1, basta que cada registo de uma tabela
   contenha o ID da outra tabela, ou seja temos um campo para uma
   tabela.
   Mas no caso de N para N, temos 2 ID's, um para cada tabela. Usando
   somente as 2 tabelas teriamos de estar a criar um novo campo em
   cada registo de cada vez que estivessemos a associar as duas. Ora
   isto não é pratico pois o trabalho de estar a criar campos numa
   tabela dinamicamente é demasiado pesado e complicado de gerir.
   A melhor solução mesmo é criar uma terceira tabela com somente dois
   campos e fazer o relacionamento nesta.
   A bottom line é que nunca sabemos a quantidade de relacionamentos
   que vamos ter entre as duas tabelas. Num relacionamento N para 1
   isto não interessa pq só temos de guardar um ID por relacionamento,
   mas em N para N temos de guardar 2 ID's, e repetir isso N vezes.

   Espero me ter feito compreender.

   Valeu galera, e bom ano novo pra todos vocês da lista, mta paz e
   luz na vida de todos vcs.

   Muito Obrigado, tudo de bom para ti tb neste novo ano !!

   Bill

 --
 Gustavo Carreno
 ---http://batxman.wordpress.com
  If you know Red Hat you know Red Hat,
 If you know Slackware you know Linux - Ocultar texto entre aspas -

 - Mostrar texto entre aspas -
--~--~-~--~~~---~--~~
Recebeu esta mensagem porque está inscrito em Grupo Cake PHP Português do 
Grupos Google.
 Para enviar mensagens para este grupo, envie um email para 
cake-php-pt@googlegroups.com
 Para anular a inscrição neste grupo, envie um email para [EMAIL PROTECTED]
 Para mais opções, visite este grupo em 
http://groups.google.com/group/cake-php-pt?hl=pt-PT
-~--~~~~--~~--~--~---



Re: Cake 1.1.X Model table name problem

2008-01-01 Thread Thrilller

hi
i too was getting this error

did what AD7six mentioned

but then i got table dont exits Error in model

even table was in DB

with lots tries

i solved it by deleting/clearing cache of Models in tmp  folder

i hope this will work

but y CAKE wasnt detecting a DB change like new table??
something to search for



On Dec 31 2007, 5:52 pm, Maken [EMAIL PROTECTED] wrote:
 i m a novice in cakephp
 i make a model with the name of lead

 class Lead extends AppModel
 {
 var $name = 'Lead';
 var $useTable = 'leads';/// changing to abc table works fine

 }

 and maken the controller like thaht

 class LeadsController extends AppController
 {
 var $name = 'Leads';

 var $uses = array(Lead);
 var $helpers = array('html','javascript');

 function index() {

 }

 }

 add made a view file index.thtml to output some dummy info

 when i run the file the flowing erreor accor

 Notice: Undefined variable: javascript in pathtoinstalliaction  \app
 \views\layouts\default.thtml on line 9

 Fatal error: Call to a member function link() on a non-object in
 pathtoinstalliaction \app\views\layouts\default.thtml on line 9

 i put the some other table name in $useTable var  and it works fine

 but when i put leads in table name is gives me about error

 is this error is due to TABLE structure (which i think so)
 or something else

 what should i do ??/

 thanks in Advance
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Help with application

2008-01-01 Thread Bill

Hi,
I am trying to create an application that uploads files, keeps track
of them, sends emails and provides upload and download links.
I want to upload a file, have it assigned to someone for translation
into another language (send an email that file was uploaded, with ftp
link(?)), upload file after translation, and create a download link
for the client. All this needs to be tracked by an admin (uploads,
file size in word count, ftp links, ...etc.). Does anyone know of
something like this that exists already, or can you get me started in
the right direction myself?
I would prefer to do this myself, since I am learning PHP and very new
to cakePHP. 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
-~--~~~~--~~--~--~---



How code a edit view with a list

2008-01-01 Thread bibi

I have a basket with many lines. I want to display all the line in a
form. User can update the quantite of each line.
How can i code my view ?
I tryed
[code]
foreach ($params['data']['Basketline'] as $Basketline) {
   echo $html-input(Basketline/$i/quantite, array('size'='4'))
   $i++;
[/code]
without succes.

Here the $params['data'] :
[code]
Array
(
[Basket] = Array
(
[id] = 13
[total] = 100.00
[nb_article] = 1
[created] = 2008-01-01 19:07:59
[modified] = 2008-01-01 19:07:59
)

[Basketline] = Array
(
[0] = Array
(
[id] = 4
[montant] = 7.00
[quantite] = 1
   )

[1] = Array
(
[id] = 5
[montant] = 8.00
[quantite] = 2
  
[/code]

Here is the edit function of my controller
[code]
function edit($id=null) {
if (empty($this-params['data']))
{   $this-params['data'] = $this-Basket-read(null,$id);
...
[/code]

--~--~-~--~~~---~--~~
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: Require SSL for entire site?

2008-01-01 Thread Chris Hartjes

On Dec 31, 2007 11:48 AM, Chris Hartjes [EMAIL PROTECTED] wrote:

 Well, if you did want to do that sort of thing you could put it in a
 beforeFilter() method in app_controller, but can you really trust the
 contents of $_SERVER['HTTPS'] to be correct?  If I understand
 correctly, that info can be spoofed along with lots of other $_SERVER
 values.


I know some people felt weird about what I said here, so I did a
little digging around and it turns out that $_SERVER['HTTPS'] cannot
be spoofed.  Good to know, because I got an IM from nate saying
because if that's possible, I need to change some stuff up.

I think using Robby's suggestion of requireSecure() and the
blackHoleCallback is the best way to go.

-- 
Chris Hartjes

My motto for 2007:  Just build it, damnit!

@TheKeyboard - http://www.littlehart.net/atthekeyboard

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



ACL ini

2008-01-01 Thread [EMAIL PROTECTED]

Hi,

I have question about ACL ini. We can check permissions by a code:

$this-Acl-check( $aro, $aco, $action );

But what about third parameter ('action')? Where we can add
information about $action in our acl.ini.php file?

We have there, by example:

[admin]
allow = Admin

And if I want that my 'admin' can only read an 'Admin' ACO, where
should I add information about it? Or maybe I can't do it and the only
way to do that is using an ACL Database?

Greetings ;-)

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



link and redirect trouble

2008-01-01 Thread Ron Astonvarga

Hello,

I've developed on localhost some code and now I transferred it to web
server and only trouble I have is:

On the page http://www.example.com/tax_classes/edit/7

I use:
$html-link(__('back to list of tax classes', true),
array('controller' = 'tax_classes', 'action'='index'));

and it generate the target url 
http://www.example.com/tax_classes/edit/tax_classes
instead of http://www.example.com/tax_classes

And I noticed it on $this-redirect();

I have a controller and a method

class CategoriesController extends AppController {

var $name = 'Categories';
var $helpers = array('Html', 'Form' );

function index() {
$this-redirect('/categories/view/5', null, true);
}
}

when I visit http://www.example.com/categories it redirects to
http://www.example.com/categories/view/5
but when i point a browser to http://www.example.com/categories/index
or http://www.example.com/categories/index/ it redirects to
http://www.example.com/categories/categories/view/5

Can somebody help me with this?
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
-~--~~~~--~~--~--~---



Problem with first cake form input name=data[....

2008-01-01 Thread lirc201

I'm having some trouble with my login form.  In my thtml file:

?php echo $html-input('Account/email',array(id = email,
class=input));?

but when I view source:

input name=data[Account][email]  id=email class=input ...

I was assuming cake would fill in name=email to correspond to the
field name in my model.

Thanks,
Brian

--~--~-~--~~~---~--~~
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: ACL ini

2008-01-01 Thread aranworld

I am mostly familiar with the AclComponent, so I don't know if this is
applicable.  In the component, the $action parameter is only fully
utilized if you are using the 'crud' mode of the AuthComponent.

If you are using the 'actions' mode of the AuthComponent, then the
$action parameter is not used, or at least is just an asterisk.  With
the 'actions' mode, which is what most tutorials are using, you end up
with acos that have aliases such as 'News/index', 'News/view/23',
'News/edit/23', 'News/delete/23'.  Because the aco uses an alias that
already has the 'action' component as part of itself, then the crud
elements of the permission table are not utilized.


On Jan 1, 1:44 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 Hi,

 I have question about ACL ini. We can check permissions by a code:

 $this-Acl-check( $aro, $aco, $action );

 But what about third parameter ('action')? Where we can add
 information about $action in our acl.ini.php file?

 We have there, by example:

 [admin]
 allow = Admin

 And if I want that my 'admin' can only read an 'Admin' ACO, where
 should I add information about it? Or maybe I can't do it and the only
 way to do that is using an ACL Database?

 Greetings ;-)

--~--~-~--~~~---~--~~
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: Child model fields

2008-01-01 Thread DaveM

Thanks for the reply.  I have tried $this-Game-Score-create(); in my
Games controller but the result is still the same as before.  Here are
the debug statements:

6 INSERT INTO `scores`
(`player_id`,`player_points`,`player_finish`,`game_id`,`created`,`modified`)
VALUES (374,'0',10,60,'2008-01-01 21:28:32','2008-01-01 21:28:32')  1
2
7 SELECT LAST_INSERT_ID() AS insertID  1 1 1
8 SELECT COUNT(id) AS count FROM `scores` WHERE `id` = 58  1 1 2
9 SELECT COUNT(id) AS count FROM `scores` WHERE `id` = 58  1 1 2
10 UPDATE `scores` SET `player_id` = 374,`player_points` =
'0',`player_finish` = 10,`game_id` = 60,`modified` = '2008-01-01
21:28:32' WHERE `id` IN (58)

As you can see, it is only pulling out one Score model from the
page.

On Jan 1, 2:05 am, soytuny [EMAIL PROTECTED] wrote:
  $this-create();

 I think, and I've had a bit to drink, should be $this-Game-Score-

 create();
 DaveM wrote:
  Hi all,

  I am trying to build a page that uses a parent model (Game) and child
  models (Score).  Game has the following fields:  id, game_number, and
  date.  Score has the following fields:  player_id, player_finish,
  player_points, and game_id.  In my scenario, there should always be 10
  Score(s) per Game.  I'd like to have the player_id, player_finish, and
  player_points rendered on the page when the Add New Game link is
  clicked.  I've defined my Score fields as follows:

  tr
  td1/td
  td?php echo $html-input('Score/player_id', array('size' = '4'))?
  /td
  td?php echo $html-input('Score/player_points', array('size' =
  '4','value' = $valueOne))?
  /?php echo $html-hidden('Score/player_finish', array('value' =
  '1')); ?
  /tr
  tr
  td2/td
  td?php echo $html-input('Score/player_id', array('size' = '4'))?
  /td
  td?php echo $html-input('Score/player_points', array('size' =
  '4','value' = $valueTwo))?/td
  ?php echo $html-hidden('Score/player_finish', array('value' =
  '2')); ?
  /tr

  I don't think this is correct.  In the save, the Game array ($this-
  data['Game']) does not contain ANY of the score domains.  The last
  Score model defined on my view is being saved.  The manual says:

  These same basic techniques will work if you're saving multiple child
  models, just place those save() calls in a loop (and remember to clear
  the model information using Model::create()).

  I tried this code thinking it would save two Score models, but it
  simply inserts one record and then updates the same record:

  $gameID = $this-Game-getLastInsertId();
  $this-data['Score']['game_id'] = $gameID;
  $this-Game-Score-save($this-data);

  $this-create();

  $gameID = $this-Game-getLastInsertId();
  $this-data['Score']['game_id'] = $gameID;
  $this-Game-Score-save($this-data);

  I'm stuck.  Any thoughts would be awesome.

--~--~-~--~~~---~--~~
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: Memcache and CakePHP

2008-01-01 Thread mehodgson



On Dec 30 2007, 11:02 am, Mike Lewis [EMAIL PROTECTED] wrote:
 So I installed memcache + added the code to core.php:

 Cache::config('default', array('engine' = 'Memcache',
              'duration' = 3600, //[optional]
              'probability' = 100, //[optional]
                  'servers' = array(
                            'memcache.ip.address'
                          ), //[optional]
                    'compress' = true,
                )
            );

 CakePHP said it detected memcache -- so whats next?

 Does it just run on its own, or do I have to add some more code to the
 actual application. If so, what is it?

 Thanks,
 Mike

All you need to do from there is use the memcache component and helper
to start caching.

A quick test for memcache:

Set your controller to cache the results of some query data that would
be displayed on the page:

if(!($someData = $this-Memcache-get('someData')))
{
//get data from DB
$someData = $this-SomeModel-find( );

//set memcached value
$this-Memcache-set('someData', $someData, 3600); //cache for one
hour
}

Upload the controller file with the memcache code and view the page to
cache the data. Then make a change to the data in the DB.  Clear your
cache and refresh the page. If the old data is displayed memcached is
working.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



New Year, New Beta

2008-01-01 Thread Larry E. Masters aka PhpNut
The CakePHP team is happy to wish everyone a wonderful new year. Entering
the 3rd year of the development we can reflect back on what was done. A year
ago, we released Cake 1.2 dev. We have worked solidly over the last year to
stabilize the new features and provide a growing platform for development.
Our goals to provide the easiest framework are coming to fruition and we
feel honored to share this with all of you. We have hit our fair share of
bumps, received our fair share of bruises, and persevered to bring together
something we can be proud of.

For this year, we would like to share CakePHP 1.2 Beta.  We can honestly and
unequivocally say this is our best release ever. The number of new features
alone make Cake a joy to use, but given the process of development we have
allowed these features to mature, finding the proper balance between
usability and extensibility. Sure, many things have changed from the
1.1days, but a lot of that old code should still work just fine. Where
we could
add, we did so with caution and care. Where we needed to rip apart, we
sliced and diced to find elegant solutions.  The end result is a
feature-rich development framework without too many significant changes.
 Most changes require a simple find and replace with clear error messages to
get you to the right place.

Some of the new features in 1.2 may seem old to people. Those in the
community who have not had a chance to try out Cake 1.2 will be happy to see
some of these features being supported by the core.

Router improvements including reverse routing for array based urls,
parseExtensions for handling multiple content types, mapResources for
handling RESTful automagic, and named arguments with a default format of
name:value.

Forms are easier to create and maintain. Including the handling of multiple
records and complex data structures. Automagic REST handling and unique
handling of GET and POST types. Forms know your model and you should thank
them for it.

Security enhancements for better CSRF prevention and HTTP Authentication.

EmailComponent handles html and text messages via templates,  layouts or on
its own. It may not look like the most full featured component, but when it
can handle attachments, html, and text there should to be too much left
wanting.

CookieComponent for securely storing persistent data on the client side

Behaviors allow the model functionality to be extended and encapsulated by
providing a simple and reusable interface. Tree and Acl included for your
enjoyment.

The with key allows you to define a dynamic join table model and access it
as your would any other model

Validation has been greatly extended to include the majority of common
validation methods

Pagination of model records with an extensive helper for neatly displaying
access to multiple pages and sorting the records

Internationalization and Localization with static translations in gettext
style or dynamic translations of model data.

Authentication component to validate user accounts tied to Access Control
made easier through the behavior to handle user permissions.

Configure class to provide dynamic handling of configuration settings and
App class to handle importing required classes

Cache Engines to provide an interface to memcache, xcache, apc, the file
system or database to help speed up your application and provide access to
persistent data.

Console is a complete mini framework for creating command line interfaces
for your application and development environment. The new console provides
an extensible shell and task system. To setup the new console, see the
screencasts http://cakephp.org/screencasts  Bake has been greatly improved
with the ability to have custom templates for views as well as directly
access specific code generation tasks. An interactive console allows you to
run code before your write it. The API shell gives you access to
documentation without digging through the code. Schema provides a versioning
and distribution interface for your database structure. ACL allows you to
CRUD your permissions and grant/deny/inherit access. The extractor makes
creating static translation files easier and faster by pulling strings from
your code.

A lot of new stuff and not a whole lot of documentation on it just yet. This
is also improving as the docs team is hard at work on
http://tempdocs.cakephp.org. We need your help as always, so if you can
spare some extra time talk to  _psychic_ or gwoo in IRC.

When you head over to http://cakephp.org you should see something new and
exciting to go along with the beta release. Once again, a special thanks to
Armando Sosa for providing the graphics and layout. Several new features and
some old ones that received a complete rewrite for 1.2.

So, out with the old and in with new. May 2008 be more exciting and
successful for everyone.
We have a lot planned, including something with a 2, a dot, and a 0.

Happy Baking,

Beta: 1.2.0.6311 http://cakeforge.org/frs/?group_id=23release_id=372