Re: Filtering using manually entered values

2007-08-10 Thread mussond

Hey, thanks for the link :)  but I'm not using 1.2 :(

The project I'm evolved with uses 1.1, hence my use of query in the
1st place.

What do you mean a POST action? using php or is it a cake 1.2 function
HttpSocket::post?

Is there a way to show my dates and send them back to the controller
using 1.1?

Cheers,

Dave

On Aug 10, 2:15 am, kabturek <[EMAIL PROTECTED]> wrote:
> Do a POST to the action when the users clicks submit in the form or
> do this with ajax if you don't want the whole page to be refreshed
>
> Also why are you using query ? its only for sql that can't be handled
> by cake and your's looks pretty basic. Generally you're doing a search
> box.
> http://wiki.kabturek.info/paginating_search_results
> 
> not all aplies for you cause you want to do it on the same page but
> look at the code and you'll find some usefull snippets
>
> greets,
>
> On Aug 10, 4:57 am, mussond <[EMAIL PROTECTED]> wrote:
>
> > I'd like to filter my view based on the input from the user.  The
> > thought is the user will enter a date range using input text boxes.
> > These values would be passed to the controller and an query($sql)
> > would return values I'll display in a table.
>
> > I can get the query and the table to work no problem but I can't find
> > a way to get the date values from the view to the controller and thus
> > be used in the query.
>
> > I've got two text inputs that contain the MIN and MAX date values from
> > the database.
>
> > start:
>
> > end:
>
> > Also the user will filter the query by selecting a user id from a
> > select box.  In my controller I set this value to the variable
> > $id_user, which is then used in the query():
>
> > $id_user = $this->data['ComUser']['id'];
>
> > $this->set('data', $this->DataPoint->query("SELECT w.com_user_id,
> > count(p.id) as c FROM data_points p join des_walks w WHERE
> > p.des_walk_id = w.id AND w.com_user_id = '$id_user' AND p.date >=
> > '2006-12-09' AND p.date <= '2006-12-10' GROUP BY w.com_user_id"));
>
> > So my question is how can I replace the '2006-12-09' and '2006-12-10'
> > with whatever is written in the text boxes?


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



Filtering using manually entered values

2007-08-09 Thread mussond

I'd like to filter my view based on the input from the user.  The
thought is the user will enter a date range using input text boxes.
These values would be passed to the controller and an query($sql)
would return values I'll display in a table.

I can get the query and the table to work no problem but I can't find
a way to get the date values from the view to the controller and thus
be used in the query.

I've got two text inputs that contain the MIN and MAX date values from
the database.

start:

end:


Also the user will filter the query by selecting a user id from a
select box.  In my controller I set this value to the variable
$id_user, which is then used in the query():

$id_user = $this->data['ComUser']['id'];

$this->set('data', $this->DataPoint->query("SELECT w.com_user_id,
count(p.id) as c FROM data_points p join des_walks w WHERE
p.des_walk_id = w.id AND w.com_user_id = '$id_user' AND p.date >=
'2006-12-09' AND p.date <= '2006-12-10' GROUP BY w.com_user_id"));

So my question is how can I replace the '2006-12-09' and '2006-12-10'
with whatever is written in the text boxes?


--~--~-~--~~~---~--~~
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: Link to a location on the same page

2007-08-08 Thread mussond

I changed the name to be #Verbs but when I click it I get redirected
to the URL: /top_tiers/index#Verbs.  This page displays exactly like /
top_tiers/index would.

I don't know how I'd implement $html->link() because it asks for a URL
and an array but I want the same array.

Has anyone got any ideas or an example for the problem?

Dave

On Aug 7, 11:55 pm, Geoff Ford <[EMAIL PROTECTED]> wrote:
> Bookmarks use #bookmarkName last time I checked.
>
> Geoff
> --http://lemoncake.wordpress.com
>
> On Aug 8, 11:50 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
>
> > On 8/7/07, mussond <[EMAIL PROTECTED]> wrote:
>
> > > Hey all, I trying to create a bookmark link on my page.  I couldn't
> > > find anything in api that would let me do this, so I've tried to do it
> > > using HTML but when I click the link I get a page saying I have a
> > > missing controller, $Verbs.
>
> > > Below is part of my HTML code.  I can see how the $Verbs controller
> > > comes about as its the name of my bookmark.  How do I get it follow
> > > the HTML and not Cake?
>
> > Why can't you use $html->link() ?
>
> > --
> > Chris Hartjes
> > Senior Developer
> > Cake Development Corporation
>
> > My motto for 2007:  "Just build it, damnit!"
>
> > @TheBallpark -http://www.littlehart.net/attheballpark
> > @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
-~--~~~~--~~--~--~---



Link to a location on the same page

2007-08-07 Thread mussond

Hey all, I trying to create a bookmark link on my page.  I couldn't
find anything in api that would let me do this, so I've tried to do it
using HTML but when I click the link I get a page saying I have a
missing controller, $Verbs.

Below is part of my HTML code.  I can see how the $Verbs controller
comes about as its the name of my bookmark.  How do I get it follow
the HTML and not Cake?


Verbs




Verbs


--~--~-~--~~~---~--~~
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: Pulling data from arrays

2007-07-23 Thread mussond

Sorry all, I was being really stupid and not implementing the arrays
correctly, encase anyone else has a problem like this heres how i did
it:








But  doesn't give me
40 but 50, so thats still not working.  Does anyone know how I should
add fields from my array?


On Jul 23, 12:06 pm, mussond <[EMAIL PROTECTED]> wrote:
> Hey all, a quick question.  I have an array that I'm trying to loop
> through in a table, using foreach:
>
> Array
> (
> [0] => Array
> (
> [w] => Array
> (
> [com_user_id] => 2
> )
>
> [0] => Array
> (
> [c] => 15
> )
>
> )
>
> [1] => Array
> (
> [w] => Array
> (
> [com_user_id] => 3
> )
>
> [0] => Array
> (
> [c] => 25
> )
>
> )
>
> )
>
> Heres my code:
>
> 
> 
> 
> 
> 
> 
> 
> 
>
> My problem is that the first [0] id isn't being increassed.  Thats
> what I put the $int in for but that doesn't get updated either.


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



Pulling data from arrays

2007-07-23 Thread mussond

Hey all, a quick question.  I have an array that I'm trying to loop
through in a table, using foreach:

Array
(
[0] => Array
(
[w] => Array
(
[com_user_id] => 2
)

[0] => Array
(
[c] => 15
)

)

[1] => Array
(
[w] => Array
(
[com_user_id] => 3
)

[0] => Array
(
[c] => 25
)

)

)

Heres my code:










My problem is that the first [0] id isn't being increassed.  Thats
what I put the $int in for but that doesn't get updated either.


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



Redirecting

2007-07-19 Thread mussond

I'm stuck on redirecting.  I'm getting a internal server error.

The idea is when I submit the form it will redirect from data_points/
index to data_points/report/$id_user.  Where $id_user is a id that the
user selected from an combo box.

Here is part of my controller code that is detecting the submit button
clicked and redirecting:

$id_user = $this->data['ComUser']['id'];

if (!empty($this->params['form']['Single']))
  {
   $this->redirect('/data_points/report/' .$id_user);

The report function should accept this id and run a query:

  function report($id)
  {
$this->set('data', $this->DataPoint->query('SELECT count(*) as c
FROM data_points p join des_walks w WHERE p.des_walk_id = w.id AND
w.com_user_id =' .$id));
  }

Finally heres my index code encase the problem is from here:



Number of Sounds

Select a Report Type and its options . . .

generateSelectDiv('ComUser/id', 'User...',
$comUser); ?>

 submit('Run Single user Report',
array('name'=>'Single')); ?>
 submit('Run Boulder users Report',
array('name'=>'Boulder')); ?>
 submit('Run ALL users Report',
array('name'=>'All')) ?>



Could anyone help me?


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



Doccumentation

2007-07-19 Thread mussond

Hey all, I know its been said before, well at least i've seen it a
couple of times.  The documentation isn't detailed.

I recall someone saying that there needs to be more newbie input about
whats lacking and things wrote and added.

What I can't remember is if there is a place to post suggestions and
examples?


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



Getting a value from generateSelectDiv()

2007-07-12 Thread mussond

Hey, I've used $form->generateSelectDiv() to generated a select tag.

In my view file I can get the values from it easily using $html-
>tagValue.

However I'm using a findCount() in my controller thats return value is
based on what the user choses in the select tag.  My problem is how
can I get the controller to use the value generated by the view?

Heres my controller code:

class DataPointsController extends AppController
{
  var $name = 'DataPoints';
  var $uses = array('DataPoint','DesWalk','ComProject','ComUser');
  var $helpers = array('Html', 'Form');

  function index()
  {
   // code to create the user ID list
   $comUser = $this->ComUser->generateList('id');
   $this->set('comUser', $comUser);
   $sql = 'SELECT count(*) AS c FROM data_points AS Data_points
WHERE data_points.des_walk_id = 1';

  // used to find the count based on the user id
   $anInt = $this->DataPoint-
>findCount(array('DataPoint.des_walk_id' => Value that the user
selects from $comUser);
$this->set('data', $anInt);
 }
}

and heres how I've created the select tag in my index view file:

generateSelectDiv('ComUser/id', 'User...',
$comUser); ?>

Can anyone help me with this?

Dave


--~--~-~--~~~---~--~~
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: Displaying a TEXT type field

2007-07-10 Thread mussond

 would be better I think in the long run :)  Thanks for your help

On Jul 10, 11:51 pm, Geoff Ford <[EMAIL PROTECTED]> wrote:
> http://www.w3schools.com/tags/tag_br.asphttp://www.w3schools.com/tags/tag_p.asp
>
> Explains the difference.
>
> Geoff
> --http://lemoncake.wordpress.com
>
> On Jul 11, 3:42 pm, mussond <[EMAIL PROTECTED]> wrote:
>
> > Thanks :), If I put  or  where I need a new line it will be on
> > a newline :)
>
> > On Jul 10, 8:52 pm, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
> > > Its a TEXT is not HTML issue.
>
> > > Text has newlines HTML has  and .
>
> > > You'll have to move beyond scaffolding to do what you want.
>
> > > Geoff
> > > --http://lemoncake.wordpress.com
>
> > > On Jul 11, 12:33 pm, mussond <[EMAIL PROTECTED]> wrote:
>
> > > > Hey all, I'm using CakePHP to display a database with German to
> > > > English translations.  It only has one table in it so I've used
> > > > scaffolding to get it up and running, which was working fine until I
> > > > noticed that my Comments field is being displayed as a string.
>
> > > > The Comments coloum is of type TEXT in the SQL and when I edit the row
> > > > or add a new one I can view it as a TEXT field with the new lines, but
> > > > when I view the list view the new lines aren't displayed.
>
> > > > encase I just lost you heres and example:
>
> > > > This is what is displayed in the table list view:  time use -> nach =
> > > > after. Going 2 some country -> nach = in.
>
> > > > But I entered the value like:
>
> > > > time use -> nach = after.
> > > > Going 2 some country -> nach = in.
>
> > > > The above is how it views if I edit the value.
>
> > > > So I'd like to find out if I can display this with the line breaks.
> > > > I'm wondering if its a HTML table issue or how the scaffolding returns
> > > > the values from the database.
>
> > > > Has anyone come across this before?
>
> > > > Thanks
>
> > > > Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How do I create a custom SQL query

2007-07-10 Thread mussond

Not sure if this has already been posted, I tired a few hours ago but
I've had net problems all day so.

Thanks for the help, I've changed my code to use findCount but I'm
having trouble with getting the correct index from $comUser.

The first index in the list (HTML select) is and id of 1, which should
return a count of 25.  but the code below returns 40.  Which is the
number of rows in the table:

$anInt = $this->DataPoint->findCount(array('DataPoint.des_walk_id' =>
$comUser));
$this->set('data', $anInt);

So I changed it so it has an index - $comUser[1] and I get the correct
count.  The same if I change the number to to 2.

My trouble is how do I change $comUser[1]  to $comUser[value that is
selected in $comUser].

I've tried $comUser[$comUser] and some variants of that idea.

Anyone now how it can be done?

On Jul 10, 3:45 am, AD7six <[EMAIL PROTECTED]> wrote:
> On Jul 6, 8:40 pm, mussond <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hey all, I have this SQL query that I want to use.  The idea is that
> > the user will select the id from a HTML select box and then click a
> > submit button.
>
> > SELECT count(*) as c
> > FROM data_points p join des_walks w
> > WHERE p.des_walk_id = w.id AND w.com_user_id = 1
>
> > I've got the following code in my controller that I put together from
> > searching on the forurm:
>
> >   function index()
> >   {
> > $this->DataPoint->recursive = 0;
> >  $this->set('datapoints', $this->DataPoint->findAll());
> >$comUser = $this->ComUser->generateList('id');
> >   $this->set('comUser', $comUser);
>
> > $sql = 'SELECT count(*) as c '
> >   . ' FROM data_points p join des_walks w '
> >   . ' WHERE p.des_walk_id = w.id AND w.com_user_id = ' .$comUser;
> > $result = $this->DataPoint->query($sql);
> > $this->set('data', $this->DataPoint->query($sql));
>
> > }
>
> what's wrong with either:
>
> $anInt = $this->DataPoint->DesWalk->findCount(array(¨DesWalk.com_user_id' => 
> $comUser))
>
> OR even
> $anInt = $this->DataPoint->DesWalk->findCount(array('User.id´ =>
> $comUser));
>
> ?
>
> I am assuming in the above you have a DesWalk model which belongs to
> User & DataPoint, if you needed a DataPoint constraint you can just
> stick it in the conditions (as done for User in the second example).
>
> I don't get why lately there are so many questions on how to use
> query, when the same can be achieved (much easier) using the methods
> of the framework.
> In this case is the method findCount not prominent enough in the docs
> (http://manual.cakephp.org/chapter/models) or something?
>
> AD


--~--~-~--~~~---~--~~
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: Displaying a TEXT type field

2007-07-10 Thread mussond

Thanks :), If I put  or  where I need a new line it will be on
a newline :)

On Jul 10, 8:52 pm, Geoff Ford <[EMAIL PROTECTED]> wrote:
> Its a TEXT is not HTML issue.
>
> Text has newlines HTML has  and .
>
> You'll have to move beyond scaffolding to do what you want.
>
> Geoff
> --http://lemoncake.wordpress.com
>
> On Jul 11, 12:33 pm, mussond <[EMAIL PROTECTED]> wrote:
>
> > Hey all, I'm using CakePHP to display a database with German to
> > English translations.  It only has one table in it so I've used
> > scaffolding to get it up and running, which was working fine until I
> > noticed that my Comments field is being displayed as a string.
>
> > The Comments coloum is of type TEXT in the SQL and when I edit the row
> > or add a new one I can view it as a TEXT field with the new lines, but
> > when I view the list view the new lines aren't displayed.
>
> > encase I just lost you heres and example:
>
> > This is what is displayed in the table list view:  time use -> nach =
> > after. Going 2 some country -> nach = in.
>
> > But I entered the value like:
>
> > time use -> nach = after.
> > Going 2 some country -> nach = in.
>
> > The above is how it views if I edit the value.
>
> > So I'd like to find out if I can display this with the line breaks.
> > I'm wondering if its a HTML table issue or how the scaffolding returns
> > the values from the database.
>
> > Has anyone come across this before?
>
> > Thanks
>
> > Dave


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



Displaying a TEXT type field

2007-07-10 Thread mussond

Hey all, I'm using CakePHP to display a database with German to
English translations.  It only has one table in it so I've used
scaffolding to get it up and running, which was working fine until I
noticed that my Comments field is being displayed as a string.

The Comments coloum is of type TEXT in the SQL and when I edit the row
or add a new one I can view it as a TEXT field with the new lines, but
when I view the list view the new lines aren't displayed.

encase I just lost you heres and example:

This is what is displayed in the table list view:  time use -> nach =
after. Going 2 some country -> nach = in.

But I entered the value like:

time use -> nach = after.
Going 2 some country -> nach = in.

The above is how it views if I edit the value.

So I'd like to find out if I can display this with the line breaks.
I'm wondering if its a HTML table issue or how the scaffolding returns
the values from the database.

Has anyone come across this before?

Thanks

Dave


--~--~-~--~~~---~--~~
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: Regarding custom queries

2007-07-10 Thread mussond

Why is $this->query() to be avoided?  I'm trying to use it but I'm
having trouble getting the values it produces from the array.

Is theres a better way for me to query tables?

oh, what I' trying to do is count the number of rows in a table bassed
on a project ID, that I get from a user ID.

On Jul 9, 11:49 pm, Geoff Ford <[EMAIL PROTECTED]> wrote:
> To clarify AD a bit
>
> Where you have:
> $this->query("UPDATE customers SET password='$pass' WHERE
> id='$id'");
>
> You should have:
> $this->id = $id;
> $this->saveField('password', $pass);
>
> You should try to avoid using $this->query() unless you really have
> to.
>
> To query the inventory table you need an Inventory model.  THen in
> your controller you can do:
> $this->Customer->changepass($id, $pass);
> $this->Inventory->findAll(array('customer_id' => $id));
>
> Or whatever it is you need to do.  Models should be independent, so
> one model should not query anothers table.  It should be done in the
> controller.
>
> I think you need to go back and read the manual a bit more.  This is
> all explained quite well.
>
> Geoff
> --http://lemoncake.wordpress.com
>
> On Jul 10, 2:12 pm, reeta <[EMAIL PROTECTED]> wrote:
>
> > Hi AD ! thanks for the help but i want to know if i want to run query
> > on another model then how could i do this?suppose i want to run
> > query() from inventory table in customer model class ,then how could i
> > do this?and another question is i m not getting value for last insert
> > id.There is a function named as getLastInsertId(),but it is not giving
> > result.
>
> > On Jul 9, 2:37 pm, AD7six <[EMAIL PROTECTED]> wrote:
>
> > > On Jul 9, 11:06 am, reeta <[EMAIL PROTECTED]> wrote:
> > > 
>
> > > > now in model class:-
> > > > function changepass($pass,$id)
> > > > {
> > > >  $this->query("UPDATE customers SET password='$pass' WHERE
> > > > id='$id'");
>
> > > Why are you using query instead of save or saveField..?
> > > If you don't want to use the features of the framework, why use the
> > > framework?
>
> > > > This is working well,but if i want to run query on another table then
> > > > how can i do this?
>
> > > You call save (or whatever) on the other model.
>
> > > hth,
>
> > > AD


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How do I create a custom SQL query

2007-07-09 Thread mussond

Brilliant thanks, that debug option is very helpful.  Correct me if
I'm wrong, I'm getting an undefined index error: DataPoint, with this
line:

 

Doesn't these values come from the controller, more specifically this
line?

$this->set('data', $this->DataPoint->query("SELECT count(*) AS c FROM
data_points AS Data_points WHERE data_points.des_walk_id = 1 "));

Hence the use of $data['DataPoint']


On Jul 9, 1:56 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> this a problem I have also when doing custom query: You have to do the
> following to get your value:
>
> 
>
> You can see the structure of the array when you do a
>
> 
>
> On Jul 9, 8:16 am, mussond <[EMAIL PROTECTED]> wrote:
>
> > Thanks :)  I got a working query now that when I use print_r gives me
> > the correct data.
>
> > But I'm having trouble displaying it.
>
> > If I did this in my controller:
>
> >  $this->set('datapoints', $this->DataPoint->findAll());
>
> > I could display the id field like this:
>
> > 
>
> > So I thought with my SQL query in the controller:
>
> > $this->set('data', $this->DataPoint->query("SELECT count(*) AS c FROM
> > data_points AS Data_points WHERE data_points.des_walk_id = 1 "));
>
> > I could then display it the same way:
>
> > 
>
> > Which doesn't work.
>
> > What am I missing?  How do you display values from and array?
>
> > Thanks
>
> > On Jul 6, 2:49 pm, dakomoon <[EMAIL PROTECTED]> wrote:
>
> > > Yea, you are getting three arrays.  The first array is the array of
> > > different models returned, the second array is the array of different
> > > rows from each model, and the third array are the columns of each
> > > row.  It might help to remember that cake collates result sets into
> > > associative arrays, but since you have no table aliases you cant see
> > > it.  For fun you might try change the query to "SELECT count(*) AS c,
> > > Data_points.somefield FROM data_points AS Data_points..." and you'll
> > > see what I'm talking about.
>
> > > hth


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How do I create a custom SQL query

2007-07-09 Thread mussond

Thanks :)  I got a working query now that when I use print_r gives me
the correct data.

But I'm having trouble displaying it.

If I did this in my controller:

 $this->set('datapoints', $this->DataPoint->findAll());

I could display the id field like this:



So I thought with my SQL query in the controller:

$this->set('data', $this->DataPoint->query("SELECT count(*) AS c FROM
data_points AS Data_points WHERE data_points.des_walk_id = 1 "));

I could then display it the same way:



Which doesn't work.

What am I missing?  How do you display values from and array?

Thanks


On Jul 6, 2:49 pm, dakomoon <[EMAIL PROTECTED]> wrote:
> Yea, you are getting three arrays.  The first array is the array of
> different models returned, the second array is the array of different
> rows from each model, and the third array are the columns of each
> row.  It might help to remember that cake collates result sets into
> associative arrays, but since you have no table aliases you cant see
> it.  For fun you might try change the query to "SELECT count(*) AS c,
> Data_points.somefield FROM data_points AS Data_points..." and you'll
> see what I'm talking about.
>
> hth


--~--~-~--~~~---~--~~
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 do I create a custom SQL query

2007-07-06 Thread mussond

Hey all, I have this SQL query that I want to use.  The idea is that
the user will select the id from a HTML select box and then click a
submit button.

SELECT count(*) as c
FROM data_points p join des_walks w
WHERE p.des_walk_id = w.id AND w.com_user_id = 1

I've got the following code in my controller that I put together from
searching on the forurm:

  function index()
  {
$this->DataPoint->recursive = 0;
 $this->set('datapoints', $this->DataPoint->findAll());
   $comUser = $this->ComUser->generateList('id');
  $this->set('comUser', $comUser);

$sql = 'SELECT count(*) as c '
  . ' FROM data_points p join des_walks w '
  . ' WHERE p.des_walk_id = w.id AND w.com_user_id = ' .$comUser;
$result = $this->DataPoint->query($sql);
$this->set('data', $this->DataPoint->query($sql));
}

I put:  in my index file to check my sql
is working and I get this:

Array ( [0] => Array ( [0] => Array ( [c] => 0 ) ) ) 1

which is slightly confussing, does it mean I'm getting 3 arrays?

I also can't get it to update when I select a different user and then
hit the submit button.

Has anyone done anything like this before?


--~--~-~--~~~---~--~~
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: Custom SQL Query

2007-07-05 Thread mussond

** Sorry if this comes up twice, my net crashed so I don't know if my
1st reply made it **

Cheers, I put it in the view but now all I get reported is "1".  I
guess my sql array bit is wrong?

On Jul 5, 3:04 pm, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On 7/5/07, mussond <[EMAIL PROTECTED]> wrote:
>
>
>
> > Should the print_r be in the controller or should that be in the view?
>
> In the view.
>
> --
> Chris Hartjes
> Senior Developer
> Cake Development Corporation
>
> My motto for 2007:  "Just build it, damnit!"
>
> @TheBallpark -http://www.littlehart.net/attheballpark
> @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
-~--~~~~--~~--~--~---



Custom SQL Query

2007-07-05 Thread mussond

Hey everyone! agian :)

I'm having another problem now, this time with custom SQL queries.  I
want to get the a count of how many sounds a user ID has uploaded into
the database, this is the SQL query:

SELECT count(*) as c
FROM data_points p join des_walks w
WHERE p.des_walk_id = w.id AND w.com_user_id = 1

The com_user_id would come from my HTMLsetelct in the view.

What I'm stuck on is getting this query submitted and then being able
to use the $result.  Heres my controller code:

  function index()
  {
$this->DataPoint->recursive = 0;
 $this->set('datapoints', $this->DataPoint->findAll());
   $comUser = $this->ComUser->generateList('id');
  $this->set('comUser', $comUser);

$sql = 'SELECT count(*) as c '
  . ' FROM data_points p join des_walks w '
  . ' WHERE p.des_walk_id = w.id AND w.com_user_id = ' .$comUser;
$result = $this->DataPoint->query($sql);
$this->set('data', $this->DataPoint->query($sql));
print_r($data);
  }

I think I'm meant to get an array from the query() function but when I
try to check using print_r I get the following error:

Notice: Undefined variable: data in /Library/WebServer/Documents/cake/
app/controllers/data_points_controller.php on line 25

Should the print_r be in the controller or should that be in the view?

I'm sure I'm doing something wrong and I've been on the forum for the
last hour looking for an answer but now I'm completely stuck

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: Using more than one Submit button

2007-06-27 Thread mussond

Apologies Grant, I've just read another post you replied to "Multiple
Action in View with Checkbox on Grid" which has solved my problem.

Thanks

On Jun 27, 2:52 pm, mussond <[EMAIL PROTECTED]> wrote:
> Thanks for the quick reply, I've been away from this project.
>
> I'm still stuck, I'm guessing I've got a syntax error somewhere, I'm
> not sure if I should put  $this->params['form']['button_name' in my
> index.thtml or my controller.
> Either way when I do I get an error message saying:
> Notice: Undefined index: Run Single user Report in /Library/WebServer/
> Documents/cake/app/controllers/data_points_controller.php on line 15
> or
> Notice: Undefined index: a in /Library/WebServer/Documents/cake/app/
> views/data_points/index.thtml on line 16
>
> Heres my index.thtml code:
>
> Number of Sounds
>
> Select a Report Type and its options . . .
> 
>
>  echo $html->selectTag('ComUser/id', $comUser, $html->tagValue('ComUser/
> id'), array(), array(), false);
> echo $html->submit('Run Single user Report');
> echo $html->submit('Run Boulder users Report');
> echo $html->submit('Run ALL users Report')?>
>
>  if ($this->params['form']['Run Single user Report'])
>{
> echo "Hi";
> }
> ?>
>
> Heres what I have if I put if statement in the controller:
>
>  class DataPointsController extends AppController
> {
>   var $name = 'DataPoints';
>   var $uses = array('DataPoint','DesWalk','ComProject','ComUser');
>   var $helpers = array('Html', 'Form');
>
>   function index()
>   {
> $this->DataPoint->recursive = 0;
>  $this->set('datapoints', $this->DataPoint->findAll());
>$comUser = $this->ComUser->generateList('id');
>   $this->set('comUser', $comUser);
>   if ($this->params['form']['Run Single user Report'])
> {
>   echo "Hi";
> }
>   }
> ?>
>
> On Jun 21, 6:51 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
>
> > I take it you would normally look at $_POST['button_name'] to see if
> > it was submitted, if so it was the one that was clicked.  You can do a
> > similar thing in Cake, just make sure the button has a unique name
> > when you add it, and look in $this->params['form']['button_name'].


--~--~-~--~~~---~--~~
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: Using more than one Submit button

2007-06-27 Thread mussond

Thanks for the quick reply, I've been away from this project.

I'm still stuck, I'm guessing I've got a syntax error somewhere, I'm
not sure if I should put  $this->params['form']['button_name' in my
index.thtml or my controller.
Either way when I do I get an error message saying:
Notice: Undefined index: Run Single user Report in /Library/WebServer/
Documents/cake/app/controllers/data_points_controller.php on line 15
or
Notice: Undefined index: a in /Library/WebServer/Documents/cake/app/
views/data_points/index.thtml on line 16

Heres my index.thtml code:

Number of Sounds

Select a Report Type and its options . . .


selectTag('ComUser/id', $comUser, $html->tagValue('ComUser/
id'), array(), array(), false);
echo $html->submit('Run Single user Report');
echo $html->submit('Run Boulder users Report');
echo $html->submit('Run ALL users Report')?>

params['form']['Run Single user Report'])
   {
echo "Hi";
}
?>

Heres what I have if I put if statement in the controller:

DataPoint->recursive = 0;
 $this->set('datapoints', $this->DataPoint->findAll());
   $comUser = $this->ComUser->generateList('id');
  $this->set('comUser', $comUser);
  if ($this->params['form']['Run Single user Report'])
{
  echo "Hi";
}
  }
?>

On Jun 21, 6:51 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> I take it you would normally look at $_POST['button_name'] to see if
> it was submitted, if so it was the one that was clicked.  You can do a
> similar thing in Cake, just make sure the button has a unique name
> when you add it, and look in $this->params['form']['button_name'].


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



Using more than one Submit button

2007-06-21 Thread mussond

I'm using 1.1 and I want several submit buttons on my form, each doing
a different action.  If I was using just PHP I would use the names of
each button and thus be able to preform different actions.  How can I
do this in Cake?


--~--~-~--~~~---~--~~
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: General gripes and questions

2007-06-04 Thread mussond

Flogging a dead horse a bit here.  But i'd agree that the
documentation needs improvement.

mainly with examples, I'm new to cake and I'm getting lost easily, I'm
currently stuck on how to create a select box and while the api is
great for telling me what function to use, the attribute details are
going right over my head.  This is where I feel examples would be
great.  :)

On Jun 4, 2:32 pm, JDS <[EMAIL PROTECTED]> wrote:
> Sounds good to me. Expect to see Trac tickets for Manual updates from
> me on a regular basis.
>
> Thanks.
>
> On Jun 4, 3:48 pm, "John David Anderson (_psychic_)"
>
> <[EMAIL PROTECTED]> wrote:
> > On Jun 4, 2007, at 12:05 PM, JDS wrote:
>
> > > On Jun 2, 11:08 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> > > 
> > >>>  * Where is it mentioned how Controllers get access to the models?
>
> > >>http://manual.cakephp.org/chapter/controllers-searchfor $uses.
>
> > >> The documentation on Model->save() is now what you have in your post.
> > >> If you just wrote that, see how quickly the documentation team (John
> > >> Anderson) responds to constuctive feedback! :)
> > > 
>
> > > See, this one line, "Your FragglesController will automatically load
> > > $this->Fraggle," is the only place that I have seen in the manual that
> > > says how the controller gets access to the model. But it seems like
> > > this very imortant information should be stated more explicitly
> > > somewhere.  Is it? Am I missing it?
>
> > Probably not.
>
> > This is better addressed in the 1.2 manual (in the works).
>
> > If you'd like to contribute to the docs, please contact me.
> > "Gripes" (your term, not mine :) on the mailing list will often go
> > unanswered, while trac tickets and contributions to the official
> > manual will actually help out the docs situation.
>
> > -- John


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

2007-06-04 Thread mussond

Thanks Joshua.  I didn't realise the two versions where so different.

I've swicthed back to the htmltag form, and can get my select box to
display but not correctly.  it just gets filled with .$user.

Heres the code:

selectTag('users', array(' . $user . ' => ' .$user .
'), null, array(), array(), true, false); ?>

If I change array(' . $user . ' => ' .$user . ') to $user the select
box gets populated with the correct number of users but not the
values, just "array".  So I'm assuming I'm not applying the index of
the array correctly, how can I do this, there isn't an example in the
api.

On Jun 4, 2:48 pm, Joshua Benner <[EMAIL PROTECTED]> wrote:
> Oh, my instructions were for Cake 1.2, as I've not really used 1.1.  For
> 1.1 information on helpers, consult the manual and api.
>
> http://manual.cakephp.orghttp://api.cakephp.org
>
> [EMAIL PROTECTED] wrote:
> > Thanks :)
>
> > I've altered my controller to use set in my index() function:
>
> >  > class DataPointsController extends AppController
> > {
> >   var $name = 'DataPoints';
> >   var $helpers = array('form');
>
> >   function index()
> >   {
> > $this->set('datapoints', $this->DataPoint->findAll());
> > $sql = 'SELECT name FROM SOLDB.com_projects';
> >$this->set('user', $this->DataPoint->query($sql));
> >   }
>
> > So I think my index.thtml file is getting the array but I'm getting a
> > new problem related to my select.
>
> > Fatal error: Call to undefined method FormHelper::select() in /Library/
> > WebServer/Documents/cake/app/views/data_points/index.thtml on line 3
>
> > Heres my index.thtml code
>
> > Data Points
> > select('users', $user, null, $user, 'User. . .'); ?>
>
> > I guess I'm setting the attributes wrong, could someone explain them
> > to me, the api confussed me.  Thank you
>
> > On Jun 4, 1:52 pm, Joshua Benner <[EMAIL PROTECTED]> wrote:
>
> >> First, I would recommend using the CakePHP Manua 
> >> (http://manual.cakephp.org).
>
> >> Passing data to a view is accomplished in the controller via:
>
> >> $this->set('varName', $value);
>
> >> A variable with the name specified in the first argument is then
> >> available in the view.
>
> >> [EMAIL PROTECTED] wrote:
>
> >>> Hey
>
> >>> I'm new to cakePHP and I'm going round in circles trying to create a
> >>> multi select box in my view.
>
> >>> I have a controller with a function users().  The function will return
> >>> the SQL query result that I want to populate my select box.
>
> >>>  >>> class DataPointsController extends AppController
> >>> {
> >>>   var $name = 'DataPoints';
>
> >>>   function index()
> >>>   {
> >>> $this->set('datapoints', $this->DataPoint->findAll());
> >>>   }
>
> >>>  function view($id = null)
> >>>  {
> >>>$this->DataPoint->id = $id;
> >>>$this->set('datapoints', $this->DataPoint->read());
> >>>  }
>
> >>>  function users()
> >>>  {
> >>>$sql = 'SELECT name FROM SOLDB.com_projects';
> >>>$result = $this->DataPoint->query($sql);
> >>>return $result;
> >>>  }
> >>> }
> >>> ?>
>
> >>> How do I use this function in my view file, index.thtml?


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