Why not relate the User Model to the Files model?

User hasMany Files...

Tarique

On Sun, Jan 30, 2011 at 5:03 PM, newguy <[email protected]> wrote:

> Hi
> I am working on implementing file upload functionality in my site, I
> have a table called users which contains user's login information.
> I want to have another table my_files with the following fields in
> which I can store the file uploaded by the user.
>
> `id`, `name`, `created`, `modified'
>
> My database.php file has this:
>
> <?php
> class DATABASE_CONFIG
> {
>   var $default = array('driver'   => 'mysql',
>                        'connect'  => 'mysql_pconnect',
>                        'host'     => 'localhost',
>                        'login'    => 'root',
>                        'password' => 'root',
>                        'database' => 'users' );
> }
> ?>
>
>
> I want to know how should I include this new table in my code and use
> it to save the uploaded file and its information.
>
> This is my view file for upload option(upload.ctp):
>
> <?php
>    echo $form->create('User', array('action' => 'upload', 'type' =>
> 'file'));
>    echo $form->file('File');
>    echo $form->submit('Upload');
>    echo $form->end();
> ?>
>
>
> This is my only model file:
> <?php
> class User extends AppModel
> {
>  var $name = 'User';
>  var $otherDB='my_files';
>  var $validate = array(
>    'username' => array(
>    'rule' => 'isUnique',
>    'message' => 'Username not available'
>    ),
>    'password' => array(
>    'rule' => array('minLength',8),
>    'message' => 'Minimum length is 8'
>    ),
>    'email' => array(
>    'rule' =>  array('email',true),
>    'message' => 'Enter valid email address'
>    )
>  );
>
>
> }
> ?>
>
> I have nothing for upload in the controller.
>
> I have read previous posts about using multiple tables but could
> really understand because of my limited knowledge in php/cake.
> 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
> [email protected]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php
>



-- 
=============================================================
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=============================================================

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to