Re: Simple SQL Query that i just cant get right

2009-09-23 Thread Steppio

Thank you all for your reponses - it works now! Just for future
reference i used Brian's last response to solve it, but they all
work.

Thank you all for your time, it is greatly appreciated!
Ste

On 23 Sep, 08:49, "Dr. Loboto"  wrote:
> As every one said, do this:
>
> $pilid = $this->Pil->find(
>     'first', // tell cake that you want one record, first one
>     array(
>         'conditions' => array('Pil.user_id' => $user_id),
>         'fields' => array('Pil.pilid'),
>         'order' => array('Pil.pilid' => 'DESC') // provide order
> preferred way
>     )
> );
>
> On Sep 23, 4:50 am, Steppio  wrote:
>
> > Hi everybody, this ones been doing my head in for some time now, hope
> > you can help me out, im sure its very simple but i just cant get it
> > working. Firstly the table structure is like this:
>
> > CREATE TABLE pil (
> >         id int(11) unsigned NOT NULL auto_increment primary key,
> >         user_id int(11) unsigned not null,
> >         pilid int(11) unsigned NOT NULL,
> >         pcode varchar(255),
> >         quantity text not null,
> >         created DATETIME,
> >         modified DATETIME
> > )ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
> > And this is inside my pils_controller.php:
>
> > function newpil() {
> >                 $user_id = $this->Session->read('User.id');
> >                 $pilid = $this->Pil->find(
> >                 array(
> >                 'conditions' => array('Pil.user_id' => $user_id),
> >                 'fields' => array('Pil.pilid'),
> >                 'order' => array('Pil.pilid DESC'),
> >                 ));
>
> >                 $pilid2 = ($pilid['Pil']['pilid'] + 1);
>
> > ...
>
> > }
>
> > What i want is for the above function to pick out the last pil
> > (product inquiry list) that the user set-up and to add a 1 to that.
>
> > Any ideas where im going wrong? Any help will be greatly appreciated.
>
> > Thank you
> > Ste
--~--~-~--~~~---~--~~
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: Simple SQL Query that i just cant get right

2009-09-22 Thread Steppio

Thanks for the response. Basically its a bit like a shopping cart. I
need a primary key just to keep each entry into the Product Inquiry
List seperate, for example some of the lines i have in the database at
the moment are:

ID |   User ID   |Pilid|pcode|   quantity   | ...
13 58   1 CM221
14 58   1 CD013
15 58   1 CM003  6
16 58   1 CM1/3   1
17 58   1 CM451  3
When i want to add a new pil i click on the function newpil(), which
at the moment does this
18 58   2  -- --
This is what i want, but when i use the function newpil() again i want
the latest pilid for that user to increment again, i.e.
19 58   3  -- --

What you have sent me worked if the Pilid was 1, it added a 1 to the
'pilid' in the find query, but once it gets
to 2 it seems to stop, just keeps being pilid = 2.

I know this is a wierd way to do it but it seemed to work in my
head :/

Again thanks for the response.

On 22 Sep, 23:06, brian  wrote:
> The first param for find() should be one of 'first', 'all', 'list', etc.
>
> But, if all you want is a single value, use field():
>
> function newpil() {
>         $pilid = $this->Pil->field(
>                 'pilid',
>                 array(
>                         'Pil.user_id' => $this->Session->read('User.id')
>                 )
>         ) + 1;
>
>         ...
>
> }
>
> That being said, I wonder if you're heading into other problems here.
> Do you know that your table will have duplicates for pilid? Because
> they will only ever be unique for a particular user_id.
>
> In fact, I don't know why you're not just using the primary key for
> this. It's an auto_increment field and is designed for just this
> purpose--increment the value for new records while also ensuring that
> it's unique across all records.
>
> On Tue, Sep 22, 2009 at 5:50 PM, Steppio  wrote:
>
> > Hi everybody, this ones been doing my head in for some time now, hope
> > you can help me out, im sure its very simple but i just cant get it
> > working. Firstly the table structure is like this:
>
> > CREATE TABLE pil (
> >        id int(11) unsigned NOT NULL auto_increment primary key,
> >        user_id int(11) unsigned not null,
> >        pilid int(11) unsigned NOT NULL,
> >        pcode varchar(255),
> >        quantity text not null,
> >        created DATETIME,
> >        modified DATETIME
> > )ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
> > And this is inside my pils_controller.php:
>
> > function newpil() {
> >                $user_id = $this->Session->read('User.id');
> >                $pilid = $this->Pil->find(
> >                array(
> >                'conditions' => array('Pil.user_id' => $user_id),
> >                'fields' => array('Pil.pilid'),
> >                'order' => array('Pil.pilid DESC'),
> >                ));
>
> >                $pilid2 = ($pilid['Pil']['pilid'] + 1);
>
> > ...
> > }
>
> > What i want is for the above function to pick out the last pil
> > (product inquiry list) that the user set-up and to add a 1 to that.
>
> > Any ideas where im going wrong? Any help will be greatly appreciated.
>
> > Thank you
> > Ste
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Simple SQL Query that i just cant get right

2009-09-22 Thread Steppio

Hi everybody, this ones been doing my head in for some time now, hope
you can help me out, im sure its very simple but i just cant get it
working. Firstly the table structure is like this:

CREATE TABLE pil (
id int(11) unsigned NOT NULL auto_increment primary key,
user_id int(11) unsigned not null,
pilid int(11) unsigned NOT NULL,
pcode varchar(255),
quantity text not null,
created DATETIME,
modified DATETIME
)ENGINE=InnoDB DEFAULT CHARSET=latin1;

And this is inside my pils_controller.php:

function newpil() {
$user_id = $this->Session->read('User.id');
$pilid = $this->Pil->find(
array(
'conditions' => array('Pil.user_id' => $user_id),
'fields' => array('Pil.pilid'),
'order' => array('Pil.pilid DESC'),
));

$pilid2 = ($pilid['Pil']['pilid'] + 1);

...
}

What i want is for the above function to pick out the last pil
(product inquiry list) that the user set-up and to add a 1 to that.

Any ideas where im going wrong? Any help will be greatly appreciated.

Thank you
Ste
--~--~-~--~~~---~--~~
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: Bypassing Security Salt

2009-07-28 Thread Steppio

The best solution that i have found is located at the bottom of this
page, basically to disable security salting from with the Auth
component within the Password function:

http://www.mail-archive.com/cake-php@googlegroups.com/msg50946.html

hope it clears up someone else's confusion too, thank you to everybody
for your help with this, its very appreciated.

Ste

On Jul 28, 11:09 am, Steppio  wrote:
> Yeah its coming back non-encrypted, thanks for the heads up, do you
> know how i would apply just sha1 encryption to it from there?
>
> On Jul 28, 6:17 am, Andras Kende  wrote:
>
> > Yes, its overwrites cake's hashPassword function to not to salt the  
> > password put the code into usually user model
> > and see if the password is encrypted in the debug display...
>
> > Andras
>
> > On Jul 27, 2009, at 4:52 PM, Steppio wrote:
>
> > > @Miles J, thanks for the post but im using alot of cookies so i need
> > > the salt value set in core, just not used in the authentication
> > > process.
>
> > > @Andras Kende, thanks mate, do you know what it does?
>
> > > On Jul 27, 9:14 pm, Andras Kende  wrote:
> > >> Hello,
>
> > >> You could try in your model:
>
> > >>   function hashPasswords($data){
> > >>      return $data;
> > >>   }
>
> > >> Andras
>
> > >> On Jul 27, 2009, at 1:53 PM, Steppio wrote:
>
> > >>> Hi there,
> > >>> I was wondering if anybody knows a way to bypass the salting that  
> > >>> the
> > >>> Security component automatically gives to a password?
>
> > >>> The problem is that i have a database of old passwords and im
> > >>> converting the site into a CakePHP site, however when im trying to  
> > >>> log
> > >>> in to the new site the password being returned by the debugger  
> > >>> appears
> > >>> to have been salted and therefore doesnt conform to my original,  
> > >>> non-
> > >>> salted sha1 password.
>
> > >>> Any help would be greatly appreciated.
>
> > >>> Thank you!
>
> > >>> Steppio
--~--~-~--~~~---~--~~
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: Bypassing Security Salt

2009-07-28 Thread Steppio

Yeah its coming back non-encrypted, thanks for the heads up, do you
know how i would apply just sha1 encryption to it from there?

On Jul 28, 6:17 am, Andras Kende  wrote:
> Yes, its overwrites cake's hashPassword function to not to salt the  
> password put the code into usually user model
> and see if the password is encrypted in the debug display...
>
> Andras
>
> On Jul 27, 2009, at 4:52 PM, Steppio wrote:
>
>
>
> > @Miles J, thanks for the post but im using alot of cookies so i need
> > the salt value set in core, just not used in the authentication
> > process.
>
> > @Andras Kende, thanks mate, do you know what it does?
>
> > On Jul 27, 9:14 pm, Andras Kende  wrote:
> >> Hello,
>
> >> You could try in your model:
>
> >>   function hashPasswords($data){
> >>      return $data;
> >>   }
>
> >> Andras
>
> >> On Jul 27, 2009, at 1:53 PM, Steppio wrote:
>
> >>> Hi there,
> >>> I was wondering if anybody knows a way to bypass the salting that  
> >>> the
> >>> Security component automatically gives to a password?
>
> >>> The problem is that i have a database of old passwords and im
> >>> converting the site into a CakePHP site, however when im trying to  
> >>> log
> >>> in to the new site the password being returned by the debugger  
> >>> appears
> >>> to have been salted and therefore doesnt conform to my original,  
> >>> non-
> >>> salted sha1 password.
>
> >>> Any help would be greatly appreciated.
>
> >>> Thank you!
>
> >>> Steppio
--~--~-~--~~~---~--~~
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: Bypassing Security Salt

2009-07-27 Thread Steppio

@Miles J, thanks for the post but im using alot of cookies so i need
the salt value set in core, just not used in the authentication
process.

@Andras Kende, thanks mate, do you know what it does?

On Jul 27, 9:14 pm, Andras Kende  wrote:
> Hello,
>
> You could try in your model:
>
>   function hashPasswords($data){
>      return $data;
>   }
>
> Andras
>
> On Jul 27, 2009, at 1:53 PM, Steppio wrote:
>
>
>
> > Hi there,
> > I was wondering if anybody knows a way to bypass the salting that the
> > Security component automatically gives to a password?
>
> > The problem is that i have a database of old passwords and im
> > converting the site into a CakePHP site, however when im trying to log
> > in to the new site the password being returned by the debugger appears
> > to have been salted and therefore doesnt conform to my original, non-
> > salted sha1 password.
>
> > Any help would be greatly appreciated.
>
> > Thank you!
>
> > Steppio
--~--~-~--~~~---~--~~
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: Bypassing Security Salt

2009-07-27 Thread Steppio

Yes thanks that helps a little, still a tad confusing though. I've
found a few more links that may be of interest to us both:

http://www.nabble.com/Auth-%3Eauthenticate-in-beforeFilter-causes-Auth-issues-td24231179.html
http://teknoid.wordpress.com/2008/10/08/demystifying-auth-features-in-cakephp-12/

I'll keep looking, thanks for your help!

Ste

On Jul 27, 7:10 pm, Piotr Kilczuk  wrote:
> Hello,
>
> > I was wondering if anybody knows a way to bypass the salting that the
> > Security component automatically gives to a password?
>
> > The problem is that i have a database of old passwords and im
> > converting the site into a CakePHP site, however when im trying to log
> > in to the new site the password being returned by the debugger appears
> > to have been salted and therefore doesnt conform to my original, non-
> > salted sha1 password.
>
> I'll be experiencing similar things in next few days (basically I have
> a IPB user database that I need to authenticate against). 
> Doeshttp://book.cakephp.org/view/566/Change-Hash-Functionhelp you?
>
> Regards,
> Piotr
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Bypassing Security Salt

2009-07-27 Thread Steppio

Hi there,
I was wondering if anybody knows a way to bypass the salting that the
Security component automatically gives to a password?

The problem is that i have a database of old passwords and im
converting the site into a CakePHP site, however when im trying to log
in to the new site the password being returned by the debugger appears
to have been salted and therefore doesnt conform to my original, non-
salted sha1 password.

Any help would be greatly appreciated.

Thank you!

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



-Connection queries

2009-01-16 Thread Steppio

Hello everybody.

I'm trying to access a website through the cake shell to use the 'Cake
schema run create DbAcl' command but have no idea how to link the IP
address / URL to the command. I've read all over te internet and
apparantly it has something to do with a '-connection' extension, i.e.
'Cake schema run create DbAcl -connection ...'.

Does anybody have any previous experience with this command? I would
be very grateful for any advice.

Thank you in advance

Ste
--~--~-~--~~~---~--~~
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: Cake ACL check

2009-01-12 Thread Steppio

Thanks for your response!

My full problem is i have groups that users belong to through a
parent_id, and when i upload the site and make groups there not
registering with the ACL (SQL Error: 1054: Unknown column
'Aro.parent_id' in 'field list' ). Normally i would run 'cake schema
run create DbAcl' command on the application using the -app extension
but in this case i need to access an uploaded website to reset the ACL
through the Shell. Bit of a weird situation i know but its got me
utterly stumped.

Again thank you for your time and response - any ideas?

On Jan 12, 5:12 am, Webweave  wrote:
> As long as everything is set up properly for your app, you can just cd
> to the app directory and run the following from a command prompt:
>
> cake schema run create DbAcl
>
> If you don't have Cake in your path, you may need to change it to be
> something like:
>
> /console/cake schema run create DbAcl
>
> I'm guessing your '-app' switch didn't work because you 
> specifiedwww.helpwriteabook.co.ukinstead of the actual path to where your app
> lives.
>
> On Jan 10, 9:48 am, Steppio  wrote:
>
> > Hi there again everybody!
>
> > Has anybody ever tried to use the command 'Cake schema run create
> > DbAcl' on a web server? im having trouble locating the correct method
> > for reseting / initializing ACL, i've tried 'cake schema run create
> > DbAcl -appwww.helpwriteabook.co.uk//test//app//'butneedless to say
> > that did'nt work. Any ideas for contacting a server through the Cake
> > Shell?
>
> > Thanks for you time in advance!
>
> > Steppio
--~--~-~--~~~---~--~~
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: Session trouble

2009-01-11 Thread Steppio

Thanks alot buddy, thats definatly tightened things up but im still
getting the odd error. Might just be me. Thanks for your help matey!

On Jan 8, 8:16 pm, "Mark (Germany)" 
wrote:
> always make sure that you check on or cast to whatever you need,
> especially reading from session!
> especially as type safety (as in java) is not one of PHP's strong
> points
>
> if it is an integer id you need to have, use (int) casting:
> $user_id = (int)$session->read('User.id')
>
> this way your input won't be filled with an array or something
> in this case, it will cast to a 0 (zero), if no valid entry was given
> the DB will prefer that one over just an empty string anyway for an
> INT field
>
> if it is a UUID, you could cast like this:
> $user_id = (string)$session->read('User.id')
>
> and if you want to populate a dropdown box (where you want to have an
> array), do this:
> $dropdownItems = (array)$session->read('User.roles')
>
> etc.
>
> On 8 Jan., 17:13, Steppio  wrote:
>
> > Hi everybody. I've been getting gip from this cheeky little number for
> > a while now, was just wondering if anybody has any insights into how i
> > could solve this problem.
> > The problem is that i'm passing the lastInsertId into the session and
> > trying to pull it out in different views, and it works alot of the
> > time, but sometimes it just has a tissy fit. I keep getting
> > this error message when passing the ID across controller/views:
>
> > SQL Error: 1366: Incorrect integer value: '' for column 'user_id' at
> > row
>
> > The site takes the users username and password, then goes onto a
> > different set of controller/views for Details, then onto Duties, and
> > finally Terms and Conditions. I find the problem happens most when i
> > reload one of the pages, for instance when im adding Details and it
> > times-out or i just reload the page. It's sometimes as if it's not
> > writing correctly to the Session, but then again it works other times.
>
> > Here's an example of how i read the session in a view:
> > read('User.id');?>
> > input('user_id', array('type' =>
> > 'hidden', 'value' => $user_id));?>
>
> > And in a controller:
> > $this->Session->read('User.id')
>
> > Any suggestions? Any help would be greatly appreciated!
> > Thank you
> > Steppio
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Cake ACL check

2009-01-10 Thread Steppio

Hi there again everybody!

Has anybody ever tried to use the command 'Cake schema run create
DbAcl' on a web server? im having trouble locating the correct method
for reseting / initializing ACL, i've tried 'cake schema run create
DbAcl -app www.helpwriteabook.co.uk//test//app//' but needless to say
that did'nt work. Any ideas for contacting a server through the Cake
Shell?

Thanks for you time in advance!

Steppio
--~--~-~--~~~---~--~~
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: Index.php's controller?

2009-01-08 Thread Steppio

Thank you! Makes administering to my Index easier!

Thank you again!

On Jan 8, 12:55 pm, "Femi Taiwo"  wrote:
> Yes you can set the default controller and action right there in routes.php.
> Look for an area that looks like this
>
> Router::connect('/', array('controller' => 'pages', 'action' =>
> 'display'));
>
> 
>
> Femi T
>
> On Thu, Jan 8, 2009 at 1:48 PM, Steppio  wrote:
>
> > Yeah that helps a little, the question mark was a typo ;P. So I could,
> > in theory, set my index to anything in routes.php?
>
> > On Jan 8, 12:34 pm, Bernardo Vieira  wrote:
> > > To none really.
>
> > > Steppio wrote:
> > > > Silly question by a silly question but to which controller does
> > > > index.php belong to? As inwww.website.com/index.php?
>
> > > > Sorry if it seems a tad basic but it's been bugging me awhile now
>
> > > > Thank you in advance for your time!
>
> > > > Ste
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Session trouble

2009-01-08 Thread Steppio

Hi everybody. I've been getting gip from this cheeky little number for
a while now, was just wondering if anybody has any insights into how i
could solve this problem.
The problem is that i'm passing the lastInsertId into the session and
trying to pull it out in different views, and it works alot of the
time, but sometimes it just has a tissy fit. I keep getting
this error message when passing the ID across controller/views:

SQL Error: 1366: Incorrect integer value: '' for column 'user_id' at
row

The site takes the users username and password, then goes onto a
different set of controller/views for Details, then onto Duties, and
finally Terms and Conditions. I find the problem happens most when i
reload one of the pages, for instance when im adding Details and it
times-out or i just reload the page. It's sometimes as if it's not
writing correctly to the Session, but then again it works other times.

Here's an example of how i read the session in a view:
read('User.id');?>
input('user_id', array('type' =>
'hidden', 'value' => $user_id));?>

And in a controller:
    $this->Session->read('User.id')

Any suggestions? Any help would be greatly appreciated!
Thank you
Steppio
--~--~-~--~~~---~--~~
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: Index.php's controller?

2009-01-08 Thread Steppio

Yeah that helps a little, the question mark was a typo ;P. So I could,
in theory, set my index to anything in routes.php?

On Jan 8, 12:34 pm, Bernardo Vieira  wrote:
> To none really.
>
> Steppio wrote:
> > Silly question by a silly question but to which controller does
> > index.php belong to? As inwww.website.com/index.php?
>
> > Sorry if it seems a tad basic but it's been bugging me awhile now
>
> > Thank you in advance for your time!
>
> > Ste
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Index.php's controller?

2009-01-08 Thread Steppio

Silly question by a silly question but to which controller does
index.php belong to? As in www.website.com/index.php?

Sorry if it seems a tad basic but it's been bugging me awhile now

Thank you in advance for your time!

Ste
--~--~-~--~~~---~--~~
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: Small problem passing variables

2009-01-07 Thread Steppio

Hello again everybody
This systems been working fine but for one problem, i keep getting
this error message when passing the ID across controller/views:

SQL Error: 1366: Incorrect integer value: '' for column 'user_id' at
row

The site takes the users username and password, then goes onto a
different set of controller/views for Details, then onto Duties, and
finally Terms and Conditions. I find the problem happens most when i
reload one of the pages, for instance when im adding Details and it
times-out or i just reload the page. It's sometimes as if it's not
writing correctly to the Session, but then again it works other times.

Here's an example of how i read the session in a view:
read('User.id');?>
input('user_id', array('type' => 'hidden', 'value'
=> $user_id));?>

And in a controller:
$this->Session->read('User.id')

Any suggestions? Any help would be greatly appreciated!
Thank you
Steppio

On Jan 3, 4:32 am, Webweave  wrote:
> It shouldn't as you are writing to the session, which is not shared
> across sessions ...
>
> On Dec 30 2008, 6:40 am, Steppio  wrote:
>
> > Ahh thank you very much, i understand now. I've used the following in
> > the controller to set the id in the session:
>
> > $user_id = $this->User->getLastInsertId();
> > $this->Session->write('User.id', $user_id);
>
> > And then i used the session helper in the view to retrieve it:
>
> > $user_id = $session->read('User.id');
>
> > echo $form->input('user_id',array('type' => 'hidden', 
> > 'value' =>
> > $user_id ));
>
> > It still returned a select box with all the ID's in, but its default
> > is the last ID, so i set it to hidden.
>
> > Say. however, two people signed up to the site simultaneously, would
> > this confuse the controller / view if configured this way, i.e. might
> > one person end up with the others ID?
>
> > Again thank you very much for your help!
>
> > On Dec 30, 2:09 pm, majna  wrote:
>
> > >http://api.cakephp.org/class_model.html#2525df39f43db3a76bff482265695d54
>
> > > getLastInsertID is wrapper for getInsertID,
> > > so getInsertID is a it faster.
> > > in controller:
> > > $this->set('user_id', $this->User->getInsertID());
>
> > > On Dec 30, 2:50 pm, Steppio  wrote:
>
> > > > Thanks to everyone for the responses its been a big help, i am still
> > > > stumped however, are getInsertID and getLastInsertID model functions?
> > > > If so how would i pass these to the views?
>
> > > > On Dec 29, 4:22 pm, Webweave  wrote:
>
> > > > > I think you meant $this->User->getLastInsertId();
>
> > > > > On Dec 28, 9:59 am, Troy Schmidt  wrote:
>
> > > > > > $this->User->getInsertID();
>
> > > > > > I don't know about the Auth component as i haven't used it alot.  
> > > > > > But
> > > > > > that would get the last inserted ID.  I would just set that variable
> > > > > > and include it in the view for the future steps.
>
> > > > > > Otherwise it looks like 'user_id' isn't set yet for user
>
> > > > > > On Dec 28, 11:11 am, Steppio  wrote:
>
> > > > > > > Hello everybody, i am totally new to Cake and am finding it quite
> > > > > > > difficult to understand all the different parts of it. At the 
> > > > > > > moment
> > > > > > > i'm trying to make a three part user registration process, firstly
> > > > > > > with the username and password fields, then onto details about the
> > > > > > > user, then on to duties they wish to undertake on the site. The 
> > > > > > > only
> > > > > > > problem i am having is once the username and password are created 
> > > > > > > it
> > > > > > > creates an ID in the users tables, referenced to my other tables 
> > > > > > > as
> > > > > > > 'user_id'. What i cannot quite figure out is how, once a user is
> > > > > > > created, would i get that user_id into the duties view? What i am
> > > > > > > doing at the moment is shown below:
>
> > > &

Re: Small problem passing variables

2008-12-30 Thread Steppio

Ahh thank you very much, i understand now. I've used the following in
the controller to set the id in the session:

$user_id = $this->User->getLastInsertId();
$this->Session->write('User.id', $user_id);

And then i used the session helper in the view to retrieve it:

$user_id = $session->read('User.id');

echo $form->input('user_id',array('type' => 'hidden', 'value' =>
$user_id ));

It still returned a select box with all the ID's in, but its default
is the last ID, so i set it to hidden.

Say. however, two people signed up to the site simultaneously, would
this confuse the controller / view if configured this way, i.e. might
one person end up with the others ID?

Again thank you very much for your help!

On Dec 30, 2:09 pm, majna  wrote:
> http://api.cakephp.org/class_model.html#2525df39f43db3a76bff482265695d54
>
> getLastInsertID is wrapper for getInsertID,
> so getInsertID is a it faster.
> in controller:
> $this->set('user_id', $this->User->getInsertID());
>
> On Dec 30, 2:50 pm, Steppio  wrote:
>
> > Thanks to everyone for the responses its been a big help, i am still
> > stumped however, are getInsertID and getLastInsertID model functions?
> > If so how would i pass these to the views?
>
> > On Dec 29, 4:22 pm, Webweave  wrote:
>
> > > I think you meant $this->User->getLastInsertId();
>
> > > On Dec 28, 9:59 am, Troy Schmidt  wrote:
>
> > > > $this->User->getInsertID();
>
> > > > I don't know about the Auth component as i haven't used it alot.  But
> > > > that would get the last inserted ID.  I would just set that variable
> > > > and include it in the view for the future steps.
>
> > > > Otherwise it looks like 'user_id' isn't set yet for user
>
> > > > On Dec 28, 11:11 am, Steppio  wrote:
>
> > > > > Hello everybody, i am totally new to Cake and am finding it quite
> > > > > difficult to understand all the different parts of it. At the moment
> > > > > i'm trying to make a three part user registration process, firstly
> > > > > with the username and password fields, then onto details about the
> > > > > user, then on to duties they wish to undertake on the site. The only
> > > > > problem i am having is once the username and password are created it
> > > > > creates an ID in the users tables, referenced to my other tables as
> > > > > 'user_id'. What i cannot quite figure out is how, once a user is
> > > > > created, would i get that user_id into the duties view? What i am
> > > > > doing at the moment is shown below:
>
> > > > > function add() {
> > > > > if (!empty($this->data)) {
> > > > > $this->User->create();
> > > > > if ($this->User->saveAll($this->data)) {
> > > > > $this->Session->setFlash(__('Your 
> > > > > Username and Password have been
> > > > > saved', true));
> > > > > $cookie = array();
> > > > > $cookie['user_id'] = 
> > > > > $this->Auth->user('user_id');
> > > > > $this->Session->write('Auth.User', 
> > > > > $cookie);
> > > > > 
> > > > > $this->redirect(array('controller'=>'details','action'=>'add'));
> > > > > } else {
> > > > > $this->Session->setFlash(__('Your 
> > > > > Username and Password could not
> > > > > be saved. Please, try again.', true));
> > > > > }
> > > > > }
> > > > > }
>
> > > > > ^users_ controller^
>
> > > > > I then call this in the 'duties/add' view with:
>
> > > > > $user_id = $session->read('User_id');
>
> > > > > echo $form->input('user_id',array('value' => $user_id 
> > > > > ));
>
> > > > > The only problem with this is Cake returns a select box populated with
> > > > > all of the id's in the user tables. All i want is the ID that has just
> > > > > been created.
>
> > > > > This is probably a very simple problem but i've been reading alot on
> > > > > the internet and just cannot understand how to do it. Any help and
> > > > > advice would be greatly appreciated!!
>
> > > > > Yours hopefully,
> > > > > Steppio
--~--~-~--~~~---~--~~
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: Small problem passing variables

2008-12-30 Thread Steppio

Ahh thank you very much, i understand now. I've used the following in
the controller to set the id in the session:

$user_id = $this->User->getLastInsertId();
$this->Session->write('User.id', $user_id);

And then i used the session helper in the view to retrieve it:

$user_id = $session->read('User.id');

echo $form->input('user_id',array('type' => 'hidden', 'value' =>
$user_id ));

It still returned a select box with all the ID's in, but its default
is the last ID, so i set it to hidden.

Say. however, two people signed up to the site simultaneously, would
this confuse the controller / view if configured this way, i.e. might
one person end up with the others ID?

Again thank you very much for your help!

On Dec 30, 2:09 pm, majna  wrote:
> http://api.cakephp.org/class_model.html#2525df39f43db3a76bff482265695d54
>
> getLastInsertID is wrapper for getInsertID,
> so getInsertID is a it faster.
> in controller:
> $this->set('user_id', $this->User->getInsertID());
>
> On Dec 30, 2:50 pm, Steppio  wrote:
>
> > Thanks to everyone for the responses its been a big help, i am still
> > stumped however, are getInsertID and getLastInsertID model functions?
> > If so how would i pass these to the views?
>
> > On Dec 29, 4:22 pm, Webweave  wrote:
>
> > > I think you meant $this->User->getLastInsertId();
>
> > > On Dec 28, 9:59 am, Troy Schmidt  wrote:
>
> > > > $this->User->getInsertID();
>
> > > > I don't know about the Auth component as i haven't used it alot.  But
> > > > that would get the last inserted ID.  I would just set that variable
> > > > and include it in the view for the future steps.
>
> > > > Otherwise it looks like 'user_id' isn't set yet for user
>
> > > > On Dec 28, 11:11 am, Steppio  wrote:
>
> > > > > Hello everybody, i am totally new to Cake and am finding it quite
> > > > > difficult to understand all the different parts of it. At the moment
> > > > > i'm trying to make a three part user registration process, firstly
> > > > > with the username and password fields, then onto details about the
> > > > > user, then on to duties they wish to undertake on the site. The only
> > > > > problem i am having is once the username and password are created it
> > > > > creates an ID in the users tables, referenced to my other tables as
> > > > > 'user_id'. What i cannot quite figure out is how, once a user is
> > > > > created, would i get that user_id into the duties view? What i am
> > > > > doing at the moment is shown below:
>
> > > > > function add() {
> > > > > if (!empty($this->data)) {
> > > > > $this->User->create();
> > > > > if ($this->User->saveAll($this->data)) {
> > > > > $this->Session->setFlash(__('Your 
> > > > > Username and Password have been
> > > > > saved', true));
> > > > > $cookie = array();
> > > > > $cookie['user_id'] = 
> > > > > $this->Auth->user('user_id');
> > > > > $this->Session->write('Auth.User', 
> > > > > $cookie);
> > > > > 
> > > > > $this->redirect(array('controller'=>'details','action'=>'add'));
> > > > > } else {
> > > > > $this->Session->setFlash(__('Your 
> > > > > Username and Password could not
> > > > > be saved. Please, try again.', true));
> > > > > }
> > > > > }
> > > > > }
>
> > > > > ^users_ controller^
>
> > > > > I then call this in the 'duties/add' view with:
>
> > > > > $user_id = $session->read('User_id');
>
> > > > > echo $form->input('user_id',array('value' => $user_id 
> > > > > ));
>
> > > > > The only problem with this is Cake returns a select box populated with
> > > > > all of the id's in the user tables. All i want is the ID that has just
> > > > > been created.
>
> > > > > This is probably a very simple problem but i've been reading alot on
> > > > > the internet and just cannot understand how to do it. Any help and
> > > > > advice would be greatly appreciated!!
>
> > > > > Yours hopefully,
> > > > > Steppio
--~--~-~--~~~---~--~~
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: Small problem passing variables

2008-12-30 Thread Steppio

Thanks to everyone for the responses its been a big help, i am still
stumped however, are getInsertID and getLastInsertID model functions?
If so how would i pass these to the views?

On Dec 29, 4:22 pm, Webweave  wrote:
> I think you meant $this->User->getLastInsertId();
>
> On Dec 28, 9:59 am, Troy Schmidt  wrote:
>
> > $this->User->getInsertID();
>
> > I don't know about the Auth component as i haven't used it alot.  But
> > that would get the last inserted ID.  I would just set that variable
> > and include it in the view for the future steps.
>
> > Otherwise it looks like 'user_id' isn't set yet for user
>
> > On Dec 28, 11:11 am, Steppio  wrote:
>
> > > Hello everybody, i am totally new to Cake and am finding it quite
> > > difficult to understand all the different parts of it. At the moment
> > > i'm trying to make a three part user registration process, firstly
> > > with the username and password fields, then onto details about the
> > > user, then on to duties they wish to undertake on the site. The only
> > > problem i am having is once the username and password are created it
> > > creates an ID in the users tables, referenced to my other tables as
> > > 'user_id'. What i cannot quite figure out is how, once a user is
> > > created, would i get that user_id into the duties view? What i am
> > > doing at the moment is shown below:
>
> > > function add() {
> > > if (!empty($this->data)) {
> > > $this->User->create();
> > > if ($this->User->saveAll($this->data)) {
> > > $this->Session->setFlash(__('Your 
> > > Username and Password have been
> > > saved', true));
> > > $cookie = array();
> > > $cookie['user_id'] = 
> > > $this->Auth->user('user_id');
> > > $this->Session->write('Auth.User', 
> > > $cookie);
> > > 
> > > $this->redirect(array('controller'=>'details','action'=>'add'));
> > > } else {
> > > $this->Session->setFlash(__('Your 
> > > Username and Password could not
> > > be saved. Please, try again.', true));
> > > }
> > > }
> > > }
>
> > > ^users_ controller^
>
> > > I then call this in the 'duties/add' view with:
>
> > > $user_id = $session->read('User_id');
>
> > > echo $form->input('user_id',array('value' => $user_id ));
>
> > > The only problem with this is Cake returns a select box populated with
> > > all of the id's in the user tables. All i want is the ID that has just
> > > been created.
>
> > > This is probably a very simple problem but i've been reading alot on
> > > the internet and just cannot understand how to do it. Any help and
> > > advice would be greatly appreciated!!
>
> > > Yours hopefully,
> > > Steppio
--~--~-~--~~~---~--~~
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: Small problem passing variables

2008-12-30 Thread Steppio

Thanks to everyone for the responses its been a big help, i am still
stumped however, are getInsertID and getLastInsertID model functions?
If so how would i pass these to the views?

On Dec 29, 4:22 pm, Webweave  wrote:
> I think you meant $this->User->getLastInsertId();
>
> On Dec 28, 9:59 am, Troy Schmidt  wrote:
>
> > $this->User->getInsertID();
>
> > I don't know about the Auth component as i haven't used it alot.  But
> > that would get the last inserted ID.  I would just set that variable
> > and include it in the view for the future steps.
>
> > Otherwise it looks like 'user_id' isn't set yet for user
>
> > On Dec 28, 11:11 am, Steppio  wrote:
>
> > > Hello everybody, i am totally new to Cake and am finding it quite
> > > difficult to understand all the different parts of it. At the moment
> > > i'm trying to make a three part user registration process, firstly
> > > with the username and password fields, then onto details about the
> > > user, then on to duties they wish to undertake on the site. The only
> > > problem i am having is once the username and password are created it
> > > creates an ID in the users tables, referenced to my other tables as
> > > 'user_id'. What i cannot quite figure out is how, once a user is
> > > created, would i get that user_id into the duties view? What i am
> > > doing at the moment is shown below:
>
> > > function add() {
> > > if (!empty($this->data)) {
> > > $this->User->create();
> > > if ($this->User->saveAll($this->data)) {
> > > $this->Session->setFlash(__('Your 
> > > Username and Password have been
> > > saved', true));
> > > $cookie = array();
> > > $cookie['user_id'] = 
> > > $this->Auth->user('user_id');
> > > $this->Session->write('Auth.User', 
> > > $cookie);
> > > 
> > > $this->redirect(array('controller'=>'details','action'=>'add'));
> > > } else {
> > > $this->Session->setFlash(__('Your 
> > > Username and Password could not
> > > be saved. Please, try again.', true));
> > > }
> > > }
> > > }
>
> > > ^users_ controller^
>
> > > I then call this in the 'duties/add' view with:
>
> > > $user_id = $session->read('User_id');
>
> > > echo $form->input('user_id',array('value' => $user_id ));
>
> > > The only problem with this is Cake returns a select box populated with
> > > all of the id's in the user tables. All i want is the ID that has just
> > > been created.
>
> > > This is probably a very simple problem but i've been reading alot on
> > > the internet and just cannot understand how to do it. Any help and
> > > advice would be greatly appreciated!!
>
> > > Yours hopefully,
> > > Steppio
--~--~-~--~~~---~--~~
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: Small problem passing variables

2008-12-30 Thread Steppio

Thanks to everyone for the responses its been a big help, i am still
stumped however, are getInsertID and getLastInsertID model functions?
If so how would i pass these to the views?

On Dec 29, 4:22 pm, Webweave  wrote:
> I think you meant $this->User->getLastInsertId();
>
> On Dec 28, 9:59 am, Troy Schmidt  wrote:
>
> > $this->User->getInsertID();
>
> > I don't know about the Auth component as i haven't used it alot.  But
> > that would get the last inserted ID.  I would just set that variable
> > and include it in the view for the future steps.
>
> > Otherwise it looks like 'user_id' isn't set yet for user
>
> > On Dec 28, 11:11 am, Steppio  wrote:
>
> > > Hello everybody, i am totally new to Cake and am finding it quite
> > > difficult to understand all the different parts of it. At the moment
> > > i'm trying to make a three part user registration process, firstly
> > > with the username and password fields, then onto details about the
> > > user, then on to duties they wish to undertake on the site. The only
> > > problem i am having is once the username and password are created it
> > > creates an ID in the users tables, referenced to my other tables as
> > > 'user_id'. What i cannot quite figure out is how, once a user is
> > > created, would i get that user_id into the duties view? What i am
> > > doing at the moment is shown below:
>
> > > function add() {
> > > if (!empty($this->data)) {
> > > $this->User->create();
> > > if ($this->User->saveAll($this->data)) {
> > > $this->Session->setFlash(__('Your 
> > > Username and Password have been
> > > saved', true));
> > > $cookie = array();
> > > $cookie['user_id'] = 
> > > $this->Auth->user('user_id');
> > > $this->Session->write('Auth.User', 
> > > $cookie);
> > > 
> > > $this->redirect(array('controller'=>'details','action'=>'add'));
> > > } else {
> > > $this->Session->setFlash(__('Your 
> > > Username and Password could not
> > > be saved. Please, try again.', true));
> > > }
> > > }
> > > }
>
> > > ^users_ controller^
>
> > > I then call this in the 'duties/add' view with:
>
> > > $user_id = $session->read('User_id');
>
> > > echo $form->input('user_id',array('value' => $user_id ));
>
> > > The only problem with this is Cake returns a select box populated with
> > > all of the id's in the user tables. All i want is the ID that has just
> > > been created.
>
> > > This is probably a very simple problem but i've been reading alot on
> > > the internet and just cannot understand how to do it. Any help and
> > > advice would be greatly appreciated!!
>
> > > Yours hopefully,
> > > Steppio
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Small problem passing variables

2008-12-28 Thread Steppio

Hello everybody, i am totally new to Cake and am finding it quite
difficult to understand all the different parts of it. At the moment
i'm trying to make a three part user registration process, firstly
with the username and password fields, then onto details about the
user, then on to duties they wish to undertake on the site. The only
problem i am having is once the username and password are created it
creates an ID in the users tables, referenced to my other tables as
'user_id'. What i cannot quite figure out is how, once a user is
created, would i get that user_id into the duties view? What i am
doing at the moment is shown below:

function add() {
if (!empty($this->data)) {
$this->User->create();
if ($this->User->saveAll($this->data)) {
$this->Session->setFlash(__('Your Username and 
Password have been
saved', true));
$cookie = array();
$cookie['user_id'] = 
$this->Auth->user('user_id');
$this->Session->write('Auth.User', $cookie);

$this->redirect(array('controller'=>'details','action'=>'add'));
} else {
$this->Session->setFlash(__('Your Username and 
Password could not
be saved. Please, try again.', true));
}
}
}

^users_ controller^

I then call this in the 'duties/add' view with:

$user_id = $session->read('User_id');

echo $form->input('user_id',array('value' => $user_id ));

The only problem with this is Cake returns a select box populated with
all of the id's in the user tables. All i want is the ID that has just
been created.

This is probably a very simple problem but i've been reading alot on
the internet and just cannot understand how to do it. Any help and
advice would be greatly appreciated!!

Yours hopefully,
Steppio

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