Re: Setting Up CakePHP on MAC with MAMP and Eclipse

2009-09-06 Thread Martin Westin

A few points for installing Cake to run in Mamp.

Simplest way is to drop the whole Cake folder (containing
cake,app,vendors...) into Mamp's htdocs folder.
Should be: /Applications/MAMP/htdocs

That should have Cake running but you probably need / want the
database too, right. You need to rename and edit the file app/config/
database.php. That file has to know how to reach Mamp's MySQL. You can
see instructions in the Mamp control panel on the port/sockets,
username, password and things.

Those are really the two common head-scratchers I know of. I can't
help you with Eclipse but if you have some specific question about the
Mamp-Cake thing let me know.

/Martin


On Sep 7, 4:59 am, FrederickD  wrote:
> Hey Kludge!
>
> Try going towww.widgetpress.comand checking out ModelBaker. It is a
> Mac front-end to CakePHP so that you never have to use the CLI. The
> product has a graphical representation of the database model you are
> creating for the project.
>
> ModelBaker is not an end-all solution. It is designed to quickly get
> you up and running with CakePHP code that you then tweak for the
> unique business logic for your project.
>
> It has some limitations as it was just released at MacWorld in
> January. Overall it promises to be a very strong product for Mac
> development with CakePHP. There is a demo version available for you to
> try out.
>
> I am not affiliated with WidgetPress at all. I do use ModelBaker
> because I'm a Mac guy and don't care much for the Terminal and command
> line interfaces anymore. Been there, did that, haven't done it for 25
> years now.
>
> Check it out!
>
> On Sep 6, 4:14 pm, Kludge  wrote:
>
>
>
> > Anyone have any idea on how to do this? I have MAMP and Eclipse
> > installed correctly and have been doing PHP development for a while
> > now and everything works fine. I now want to jump into CakePHP but
> > can't wrap my head around setting it up. Any insight and or steps on
> > getting there would be great. Thank you in advance!
--~--~-~--~~~---~--~~
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: Can you paginate an array of data without going to the DB to find it?

2009-09-06 Thread DavidH

Yes I looked at the custom query pagination; but the reason that is no
good is in the title 'query'. I'm not doing a query on a database I've
already got my data set that I want to paginate.

Well I guess the custom query pagination is the way to go in that I'll
have to override the existing paginate and paginatecount methods and
write ones that don't try a database access. I would have rather not
had to go that route due to time & budget constraints. Oh well..

On Sep 7, 3:34 am, "Dr. Loboto"  wrote:
> You can try custom query 
> pagination.http://book.cakephp.org/view/249/Custom-Query-Pagination
>
> On Sep 6, 11:53 pm, DavidH  wrote:
>
> > Hi
>
> > I'm using CakePHP as a development framework; but my data is stored /
> > retrieved in documents from a Couch DB. I've written home grown
> > classes to access the Couch and have turned off Cake's desire for a
> > DBMS by creating my own dbo_source that just returns true making Cake
> > think it's connected OK.
>
> > In my index action I can query a Couch view and get a data set back
> > and then massage it into a Cake array structure. I'd like to paginate
> > this before the index.ctp gets invoked; but paginate tries to get
> > things from the database and, of course, then methods it wants aren't
> > defined in my dbo_source file.
>
> > Is there a way to say "Paginate this" and pass paginate an existing
> > cake array of data to paginate?
>
> > Thanks
>
> > David
--~--~-~--~~~---~--~~
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: Should id be hidden value?

2009-09-06 Thread Jamie

Well, are you just new to CakePHP, or PHP in general? Because remember
that CakePHP is really just PHP. And just like with any PHP-driven
webpage that uses database tables with unique IDs, you need to pass
the ID in the form somehow. You just need to do some security/sanity
checks when processing the form to ensure that the user isn't doing
anything bad. For example, make sure that the user editing the form
has permission to edit the ID in question.

- Jamie

On Sep 6, 6:32 am, thesti  wrote:
> hi,
>
> i'm learning CakePHP and i take the Blog tutorial.
>
> and as i came to the modifying a post part, it's written that if we
> supply the 'id' field to the FormHelper then the form will be used to
> edit a post.
>
> when i see the source page, i see that the id is there as a hidden
> Input in the edit form. is there any other way in cake to make an edit
> form?
>
> because with javascript we can edit Hidden Input value and i think
> it's not secure.
>
> Thanks
--~--~-~--~~~---~--~~
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: Using a Button to Submit an AJAX Form

2009-09-06 Thread Shaun

The solution is to use this:

$form->button('Submit', array('type' => 'submit'));

Not this:

$form->button('Submit', array('onclick' => 'this.form.submit()'));
--~--~-~--~~~---~--~~
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: Setting Up CakePHP on MAC with MAMP and Eclipse

2009-09-06 Thread FrederickD

Hey Kludge!

Try going to www.widgetpress.com and checking out ModelBaker. It is a
Mac front-end to CakePHP so that you never have to use the CLI. The
product has a graphical representation of the database model you are
creating for the project.

ModelBaker is not an end-all solution. It is designed to quickly get
you up and running with CakePHP code that you then tweak for the
unique business logic for your project.

It has some limitations as it was just released at MacWorld in
January. Overall it promises to be a very strong product for Mac
development with CakePHP. There is a demo version available for you to
try out.

I am not affiliated with WidgetPress at all. I do use ModelBaker
because I'm a Mac guy and don't care much for the Terminal and command
line interfaces anymore. Been there, did that, haven't done it for 25
years now.

Check it out!

On Sep 6, 4:14 pm, Kludge  wrote:
> Anyone have any idea on how to do this? I have MAMP and Eclipse
> installed correctly and have been doing PHP development for a while
> now and everything works fine. I now want to jump into CakePHP but
> can't wrap my head around setting it up. Any insight and or steps on
> getting there would be great. Thank you in advance!
--~--~-~--~~~---~--~~
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: How is the difference between Model::query() and Model::execute()?

2009-09-06 Thread Dr. Loboto

Cake 1.1 had 2 methods - query() for queries that return data (like
SELECT) and execute() for those who don't (like UPDATE). In Cake 1.2
execute() method is deprecated and you should use query() for both
types of custom queries.

On Sep 5, 10:53 pm, cogitovn  wrote:
> I looked up in cakePHP Manual 1.2 and 1.1, but not found the answer.
> Thanks in advance for any answer.
--~--~-~--~~~---~--~~
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: Query Help

2009-09-06 Thread Dr. Loboto

Looks like you just forgot enclose your custom sql into brackets.

array(
 'Post.status' => 0,
 'Post.rank <=' => $rank,
 '('.$sql.')'
)

On Sep 7, 1:56 am, "Dave Maharaj :: WidePixels.com"
 wrote:
> For some reason this query is pulling more results then that which is
> possible.
>
> I am running a contain
>
> $params = array('contain' => false,
>       'conditions' => array(            
>              'Post.status' => 0,
>              'Post.rank <=' => $rank,
>                $sql
>              ),
>       'fields' => array('Post.id'));
>
> which produces this
>
> SELECT `Post`.`id` FROM `posts` AS `Post` WHERE `Post`.`status` = 0 AND
> `Post`.`rank` <= 0 AND `Post`.`title` LIKE '%mary%' OR `Post`.`description`
> LIKE '%mary%'
>
> So I get these id's returned
>
> Array
> (
>     [0] => 139ea7
>     [1] => 2a4370
>     [2] => 3fb952
>     [3] => 66bfb4
>     [4] => 8197d5
>     [5] => 87c28a
>     [6] => 97fd0f
>     [7] => a78629
>     [8] => cbe69d
>     [9] => e9915c
> )
>
> Yet there are only 5 Posts in the db that have a rank of 0,  seems like its
> ignoring the rank and status and just and pulling the `Post`.`title` LIKE
> '%mary%' OR `Post`.`description` LIKE '%mary%'
>
> Any ideas why? Or how to only get id's where I am going wrong here?
>
> Dave
--~--~-~--~~~---~--~~
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: Should id be hidden value?

2009-09-06 Thread Dr. Loboto

ID must be passed. It can be done through form hidden field or through
URL. Choose your way. For security check passed id in controller.

On Sep 6, 8:32 pm, thesti  wrote:
> hi,
>
> i'm learning CakePHP and i take the Blog tutorial.
>
> and as i came to the modifying a post part, it's written that if we
> supply the 'id' field to the FormHelper then the form will be used to
> edit a post.
>
> when i see the source page, i see that the id is there as a hidden
> Input in the edit form. is there any other way in cake to make an edit
> form?
>
> because with javascript we can edit Hidden Input value and i think
> it's not secure.
>
> Thanks
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HttpSocket, Twitter Datasource, and an unexpected response

2009-09-06 Thread archF6

I have implemented the Twitter Datasource found in the bakery [
http://bakery.cakephp.org/articles/view/twitter-datasource ] which
uses Http Socket to send a GET request to Twitter, and parses the XML
response into an array.

Everything works great about 95% of the time, however, after long
periods of inactivity (usually my first use of the app of the day),
the request's response is an HTML file with a refresh metadata tag
(with a .1 second content attribute).  This data is transformed into
an array by the __process method of the datasource.  I can debug the
response before it's turned into an array by logging it.  The response
code is 200, success. The entire response is here:

http://www.w3.org/
TR/1999/REC-html401-19991224/strict.dtd">











So 2 questions... 1) Is anyone else retrieving this response from
Twitter?  and 2) if this is a response from Twitter, will outputting
the response allow for the refresh to occur?  In other words, will
HTTP socket know how to handle this response if I'm not transforming
it into an array before outputting it?  It's hard for me to test
against this because the error appears inconsistently.

Also probably worth mentioning, I'm using $this->disableCache() in my
controller, but looking at the disableCache method in /cake/libs/
controller/controller.php, doesn't look like this response is being
generated by Cake.

Here's also a stripped down version of my tweets controller, in case
I'm missing something else that might explain why I'm getting that
response:

function beforeFilter(){
parent::beforeFilter();

/*
 * Load up the ConnectionManager and connect to the Twitter
datasource:
 * http://bakery.cakephp.org/articles/view/twitter-datasource
 * If username and password are set in session after
successful login within
 * index method, set Twitter DS username and password so all
preceeeding
 * requests are authenticated, and don't count against IP rate
limit
 */
$this->Twitter = ConnectionManager::getDataSource('twitter');
if($this->Session->read('Twitter.username') && $this->Session-
>read('Twitter.password')):
$this->Twitter->username = $this->Session->read
('Twitter.username');
$this->Twitter->password = $this->Session->read
('Twitter.password');
$this->loggedIn = true;
endif;

/*
 * If a user has requested a method other than index, but has
not logged in,
 * send them back to the index method
 */
if($this->action != 'index' && !$this->loggedIn):
$this->redirect(array('action' => 'index'));
endif;

}

function index(){
$this->disableCache();

if($this->loggedIn):
$this->redirect(array('action' => 'select'));

elseif(!empty($this->data)):
$this->Twitter->username = $this->data['Tweet']
['username'];
$this->Twitter->password = $this->data['Tweet']
['password'];
$response = $this->Twitter->account_verify_credentials();

if(isset($response['User'])):
$this->Session->write('Twitter.username', $this->data
['Tweet']['username']);
$this->Session->write('Twitter.password', $this->data
['Tweet']['password']);
$this->Session->write('Twitter.followers', $response
['User']['followers_count']);
$this->redirect(array('action' => 'select'));

elseif(isset($response['Hash']['error'])):
$this->data['Tweet']['password'] = '';
$this->Session->setFlash('Invalid username or
password.  Please try again.');

else:
$this->data['Tweet']['password'] = '';
debug($response);
$this->Session->setFlash('Twitter returned something
unexpected:' . $response);

endif;

endif;
}

function select($page = 1){
$this->disableCache();

//this is just a method that retrieves a list of the logged in
user's followers
//either retrieved from cache, or via datasource if proper
cache file isn't found...
$this->set('followers', $this->_getFollowers($page));
$this->set('page', $page);


if($this->RequestHandler->isAjax()):
$this->render('select_more');
endif;
}


Thanks in advance!
--~--~-~--~~~---~--~~
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: HttpSocket, Twitter Datasource, and an unexpected response

2009-09-06 Thread archF6

Just to follow up, after a bit of digging, it appears this is a
documented issue with Twitter that's been showing up for a few weeks
now [ 
http://groups.google.com/group/twitter-development-talk/browse_thread/thread/88506e01a9c1a4e4
], [
http://groups.google.com/group/twitter-development-talk/browse_thread/thread/acdcb4baf76037c8/e0ac9745e4c9bfe9?lnk=gst&q=refresh#e0ac9745e4c9bfe9
].

So my question is now a bit more focused; since the response IS coming
from Twitter, so do I best handle this kind of response?  If I simply
search for this specific string, and echo it, and exit(), will http
socket make the same request, pass all parameters a second time,
including auth, and return the data properly via the datasource in the
refresh request?  If not, any ideas how I might go about handling?
--~--~-~--~~~---~--~~
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: Can you paginate an array of data without going to the DB to find it?

2009-09-06 Thread Dr. Loboto

You can try custom query pagination. 
http://book.cakephp.org/view/249/Custom-Query-Pagination

On Sep 6, 11:53 pm, DavidH  wrote:
> Hi
>
> I'm using CakePHP as a development framework; but my data is stored /
> retrieved in documents from a Couch DB. I've written home grown
> classes to access the Couch and have turned off Cake's desire for a
> DBMS by creating my own dbo_source that just returns true making Cake
> think it's connected OK.
>
> In my index action I can query a Couch view and get a data set back
> and then massage it into a Cake array structure. I'd like to paginate
> this before the index.ctp gets invoked; but paginate tries to get
> things from the database and, of course, then methods it wants aren't
> defined in my dbo_source file.
>
> Is there a way to say "Paginate this" and pass paginate an existing
> cake array of data to paginate?
>
> Thanks
>
> David
--~--~-~--~~~---~--~~
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: Undefined variable when using a custom helper

2009-09-06 Thread Dr. Loboto

Helpers are for views, not controllers. Of course it do not exists in
controller.

On Sep 6, 8:14 pm, troven  wrote:
> I've searched the net for an answer to the following error:
>     Notice (8): Undefined variable: commons [APP/controllers/
> profiles_controller.php, line 2388]
>
> I've declared it in my Controller - as you can see from the debug
> output:
>
> Array
> (
>     [0] => Commons     THIS IS IT
>     [1] => Html
>     [2] => Form
>     [3] => Ajax
>     [4] => Javascript
>     [5] => Cs
>     [6] => Display
>     [7] => Time
>     [8] => Google
> )
>
> Here's the stack trace, if that helps:
>
> ProfilesController::add() - APP/controllers/profiles_controller.php,
> line 2388
> Object::dispatchMethod() - CORE/cake/libs/object.php, line 122
> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227
> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194
> [main] - APP/webroot/index.php, line 88
>
> 100 GEEK GOD points if you track it done.
>
> BTW: Loving my first foray into CakePHP. Shame that the project is to
> re-factor someone else's horrid source.
--~--~-~--~~~---~--~~
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: How is the difference between Model::query() and Model::execute()?

2009-09-06 Thread cogitovn
In another project, I could use execute() for SELECT statements, even that
SELECT statements getting data from more than one table.
So, I don't understand What "execute() is
called privately within the Model class." is.
Please explain more details.
Thank you!

2009/9/6 euromark (munich) 

>
> same as without cake!
> usually execute "executes" (boolean true/false)
> and query can fetch, update, delete, insert...
>
> in cake you usually need only query
>
>
> On 5 Sep., 22:12, Miles J  wrote:
> > query() is used by you manually within your Models. execute() is
> > called privately within the Model class.
> >
>

--~--~-~--~~~---~--~~
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: Media Plugin

2009-09-06 Thread David Persson

Hey Robert,

The paths you get from the MediumHelper to they point to existing
assets (try accessing the path directly). What is the actual HTML
which gets rendered when you use embed(...) ?> ?

MediumHelper::file() is quite flexible it takes both a single string
argument as well as an array (like the ones you get as results from
the Attachment model) having both a 'dirname' and 'basename' key/value
pair.

The model name should get stored in the table if you're using the
provided element. How does the data array look like you're saving to
the db?

-David


On 4 Sep., 19:49, robert matousek  wrote:
> I'm hoping someone can help me use the Media Plugin developed by David
> Persson.
> First of all, I used the Attachment model to save some images. When I
> try to render them using the MediumHelper, it generates the correct
> paths, but images aren't showing? Any idea why?
>
> e.g. /media/filter/s/transfer/img/name.png
>
> What is the best way to use the MediumHelper file function? In the
> slides it give two arguments, but when I look at the method it only
> takes 1. Examples anybody?
>
> Last but not least, its not storing the Model name in the model column
> of the Attachment tabel? How do I fix this?
>
> Given all the awesome functionality, it seems like its worth the extra
> effort to use this plugin!
>
> Robert Matousek
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Setting Up CakePHP on MAC with MAMP and Eclipse

2009-09-06 Thread Kludge

Anyone have any idea on how to do this? I have MAMP and Eclipse
installed correctly and have been doing PHP development for a while
now and everything works fine. I now want to jump into CakePHP but
can't wrap my head around setting it up. Any insight and or steps on
getting there would be great. Thank you in advance!

--~--~-~--~~~---~--~~
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: What do messages in Debugkit Timer mean?

2009-09-06 Thread nologicon


I was wondering that myself.  Anyone?
-- 
View this message in context: 
http://n2.nabble.com/What-do-messages-in-Debugkit-Timer-mean-tp3460593p3594484.html
Sent from the CakePHP mailing list archive at Nabble.com.

--~--~-~--~~~---~--~~
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: Query Help

2009-09-06 Thread Dave Maharaj :: WidePixels.com

Because the $sql is built from the input separated by , so it will search
Mary, Tom as 

SELECT `Post`.`id` FROM `Posts` AS `Post` WHERE `Post`.`status` = 0 AND
`Post`.`rank` <= 0 AND `Post`.`title` LIKE '%mary%' OR `Post`.`description`
LIKE '%mary%' OR `Post`.`title` LIKE '%tom%' OR `Post`.`description` LIKE
'%tom%' 

And not LIKE '%marytom%'

It creates a string based on the values entered into the search.

-Original Message-
From: Miles J [mailto:mileswjohn...@gmail.com] 
Sent: September-06-09 6:07 PM
To: CakePHP
Subject: Re: Query Help


Why dont you just use the built it or mechanics?

'OR' => array('Post.title LIKE' => '%'. $value .'%', 'Post.description LIKE'
=> '%'. $value .'%') 

--~--~-~--~~~---~--~~
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: Query Help

2009-09-06 Thread Miles J

Why dont you just use the built it or mechanics?

'OR' => array('Post.title LIKE' => '%'. $value .'%', 'Post.description
LIKE' => '%'. $value .'%')
--~--~-~--~~~---~--~~
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: Query Help

2009-09-06 Thread Dave Maharaj :: WidePixels.com

The $sql is created with this:

$i=0;  // This is each counter
// Now build SQL String
$sql = "";
foreach ($string as $key => $value)
{
$value = trim($value);
//strip white space befor and after each term
$sql.= "Post.title LIKE '%" . $value . "%' OR
Post.description LIKE '%" . $value . "%'";
$i++;  // Put your counter up by 1
if($i < count($string))  // Check if your counter is
smaller than amount of values in array, if there are still values, add a OR
{
$sql.=" OR ";
}
} 

So it ends up with `Post`.`title` LIKE '%mary%' OR `Post`.`description` LIKE
'%mary%'

-Original Message-
From: Miles J [mailto:mileswjohn...@gmail.com] 
Sent: September-06-09 4:42 PM
To: CakePHP
Subject: Re: Query Help


It seems like the OR is breaking it. What does the $sql variable look like?


--~--~-~--~~~---~--~~
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: Query Help

2009-09-06 Thread Miles J

It seems like the OR is breaking it. What does the $sql variable look
like?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Query Help

2009-09-06 Thread Dave Maharaj :: WidePixels.com

For some reason this query is pulling more results then that which is
possible.

I am running a contain 
 
$params = array('contain' => false,
  'conditions' => array( 
 'Post.status' => 0,
 'Post.rank <=' => $rank,
   $sql
 ),
  'fields' => array('Post.id'));
 
which produces this 
 
SELECT `Post`.`id` FROM `posts` AS `Post` WHERE `Post`.`status` = 0 AND
`Post`.`rank` <= 0 AND `Post`.`title` LIKE '%mary%' OR `Post`.`description`
LIKE '%mary%'

So I get these id's returned

Array
(
[0] => 139ea7
[1] => 2a4370
[2] => 3fb952
[3] => 66bfb4
[4] => 8197d5
[5] => 87c28a
[6] => 97fd0f
[7] => a78629
[8] => cbe69d
[9] => e9915c
)

Yet there are only 5 Posts in the db that have a rank of 0,  seems like its
ignoring the rank and status and just and pulling the `Post`.`title` LIKE
'%mary%' OR `Post`.`description` LIKE '%mary%'

Any ideas why? Or how to only get id's where I am going wrong here?
 
Dave 


--~--~-~--~~~---~--~~
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: Need a bit of help with the delete function

2009-09-06 Thread Miles J

No you dont need to the name the index in the array, you only do that
for routed pages and named arguments.

$html->link('Delete', array('action' => 'delete', $fullname['Fullname']
['name_id']), null, 'Are you sure?' );
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Can you paginate an array of data without going to the DB to find it?

2009-09-06 Thread DavidH

Hi

I'm using CakePHP as a development framework; but my data is stored /
retrieved in documents from a Couch DB. I've written home grown
classes to access the Couch and have turned off Cake's desire for a
DBMS by creating my own dbo_source that just returns true making Cake
think it's connected OK.

In my index action I can query a Couch view and get a data set back
and then massage it into a Cake array structure. I'd like to paginate
this before the index.ctp gets invoked; but paginate tries to get
things from the database and, of course, then methods it wants aren't
defined in my dbo_source file.

Is there a way to say "Paginate this" and pass paginate an existing
cake array of data to paginate?

Thanks

David
--~--~-~--~~~---~--~~
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: Should id be hidden value?

2009-09-06 Thread stefan blickensdoerfer

hi

baked views should not be used as final solution for an application.

but you can use the security component to avoid manipulation of form data.

regards



On Sun, Sep 6, 2009 at 3:32 PM, thesti wrote:
>
> hi,
>
> i'm learning CakePHP and i take the Blog tutorial.
>
> and as i came to the modifying a post part, it's written that if we
> supply the 'id' field to the FormHelper then the form will be used to
> edit a post.
>
> when i see the source page, i see that the id is there as a hidden
> Input in the edit form. is there any other way in cake to make an edit
> form?
>
> because with javascript we can edit Hidden Input value and i think
> it's not secure.
>
> Thanks
>
> >
>

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



Should id be hidden value?

2009-09-06 Thread thesti

hi,

i'm learning CakePHP and i take the Blog tutorial.

and as i came to the modifying a post part, it's written that if we
supply the 'id' field to the FormHelper then the form will be used to
edit a post.

when i see the source page, i see that the id is there as a hidden
Input in the edit form. is there any other way in cake to make an edit
form?

because with javascript we can edit Hidden Input value and i think
it's not secure.

Thanks

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



Undefined variable when using a custom helper

2009-09-06 Thread troven

I've searched the net for an answer to the following error:
Notice (8): Undefined variable: commons [APP/controllers/
profiles_controller.php, line 2388]

I've declared it in my Controller - as you can see from the debug
output:

Array
(
[0] => Commons THIS IS IT
[1] => Html
[2] => Form
[3] => Ajax
[4] => Javascript
[5] => Cs
[6] => Display
[7] => Time
[8] => Google
)

Here's the stack trace, if that helps:

ProfilesController::add() - APP/controllers/profiles_controller.php,
line 2388
Object::dispatchMethod() - CORE/cake/libs/object.php, line 122
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194
[main] - APP/webroot/index.php, line 88

100 GEEK GOD points if you track it done.

BTW: Loving my first foray into CakePHP. Shame that the project is to
re-factor someone else's horrid source.


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



Auth problem. Please help

2009-09-06 Thread Veoempleo

Hello,

I've configure the auth module in app_controller, and in a user view I
use swfupload script to upload an image. When it is completed, it
launch windows.location.reload()

The module upload image and update db, BUT when the javascript launch
windows.location.reload(), auth finalize session:

- how could I check the error?
- Where is the error?

Thank you in advantage
--~--~-~--~~~---~--~~
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: Using a Button to Submit an AJAX Form

2009-09-06 Thread Shaun

The $form->button still reloads the page because I'm using ('onclick'
=> 'this.form.submit()')

Is there any way to use a button to submit the data without reloading
the page?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Neighbors help.

2009-09-06 Thread Dave Maharaj :: WidePixels.com
I am having some problems with finding neighbors in pagination. I have a
standard index whichs lists all the post -> view get the neighbours ok that
works no problem.
 
view function :
this gets me the posts before and after $post_id I pass

$neighbors = $this->Post->__getNeighbors($post_id, $rank,
$post['Post']['created']);
<.>
 
My problem comes when viewing pages that come from a pagination. 
The view function will get the same neighbours obviously because the
variables re the same. What I need to do is pass the variables from one
function to the view from within the controller.
 
 Could I do something like this?
 
function view($post_id)
$params = $this->Session->read('User.Paginate');
$neighbors = $this->Post->__getNeighbors($post_id, $params);
$this->set(compact('neighbors'));
 
function search()
//search renders standard index.ctp view
//do what i need to do to create the pagination and set the params for the
neighbors and save them to the session
$query = Sanitize::paranoid($this->data, array(' ',','));
$string = $query['Job']['query'];
$posts = $this->Post->__quickQuery($string,
$this->Session->read('Auth.User.rank'));
$params = array'Post.rank => $this->Session->read('Auth.User.rank'),
'Post.created' => $z)
$this->Session->write(User.Paginate, $params);
 
function advancedsearch()
//search renders standard index.ctp view
//do what i need to do to create the pagination and set the params for the
neighbors and save them to the session
$query = Sanitize::paranoid($this->data, array(' ',','));
$string = $query['Job']['query'];
$posts = $this->Post->__advancedQuery($string,
$this->Session->read('Auth.User.rank'));
$params = array'Post.rank => $this->Session->read('Auth.User.rank'),
'Post.created' => $z)
$this->Session->write(User.Paginate, $params);
 
So basicaly the idea is to save the params to the seesion in one function so
another function can read it... 
 
Ideas, thoughts?
 
Thanks
Dave 

--~--~-~--~~~---~--~~
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 cant find model's method!!!

2009-09-06 Thread Dr. Loboto

With such names I better check code and model filename for
misspellings. I guess that this model filename should be
enrollees_offered_subject.php

Remember, that if cake do not find file with model it loads AppModel
instead. And if model name is conventional and table exists, all seems
normal until use associations / call custom methods -> that obviously
do not work.

P.S. I can swear that all your long post is completely unrelated and
only real name of model have sense.
--~--~-~--~~~---~--~~
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: My behavior does not work with containable

2009-09-06 Thread schneimi

This is really unfortunately.

Anyway, I found an old patch/hack for the core and made it work with
the latest CakePHP 1.2.4.8284. Because this may help others as well, I
put it on my blog: 
http://schneimi.wordpress.com/2009/09/06/behavior-afterfind-on-model-associations/

On 5 Sep., 16:44, brian  wrote:
> Behavior methods of associated models are not triggered, unfortunately.
>
> On Sat, Sep 5, 2009 at 5:21 AM, schneimi wrote:
>
> > Hi,
>
> > I have created a simple behavior that can serialize (beforeSave) and
> > unserialize (afterFind) certain fields of a model.
>
> > If I do an action directly on the model like $this->Model->find(...),
> > I get the unserialized data, but if I catch the Model fields with
> > containable like $this->OtherModel->contain('Model');$this->OtherModel-
> >>find(...);, the behavior isn't used at all and I only get the
> > serialized data.
>
> > Is this a problem with my model setup, the containable behavior, or a
> > general limitation of behaviors?
>
> > Thx,
> > Michael
--~--~-~--~~~---~--~~
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: Parsing image BB with HTML helper

2009-09-06 Thread BeroFX

Okay, I know I wasn't crazy, after 3 hours of searching, I found it.

http://www.gersh.no/posts/view/embed_images_anywhere_in_cakephp

--~--~-~--~~~---~--~~
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: Need a bit of help with the delete function

2009-09-06 Thread Russell

Just change the url

$html->link('Delete', array('action' => 'delete', 'id' =>
$fullname['Fullname']['name_id']), null, 'Are you sure?' )


 to


 $html->link('Delete', array('action'=>'delete',$fullname['Fullname']
['name_id'], array('escape' => false), sprintf(__('Are you sure ?',
true), $fullname['Fullname']['name_id']));
hope it will howk.


thanks,
Russell


On Sep 5, 10:08 pm, Whitty  wrote:
> Hi,
>
> I've just started using cakephp, and I'm working on a small program, I
> have an existing db which has a table ID  called name_id
>
> but I'm unable to delete records from the table using this id using
> the delete function
>
> here is an example of the code:
>
> this is the function:
>
>     function delete($id) {
>             $this->Fullname->delete($id);
>             $this->Session->setFlash('The name with id: '.$id.' has been
> deleted.');
>             $this->redirect(array('action'=>'index'));
>     }
>
> and the calling code:
>
> $html->link('Delete', array('action' => 'delete', 'name_id' =>
> $fullname['Fullname']['name_id']), null, 'Are you sure?' )
>
> I'm getting Missing argument 1 for FullNamesController::delete()
>
> in the url I'm seeing "delete/name_id:36", how do I get this function
> to work, I dont want to change the id as the db I use depends on an
> existing program?
>
> Thanks in advance, Darren
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Parsing image BB with HTML helper

2009-09-06 Thread BeroFX

Hi guys!

I saw a really neat piece of code a few weeks ago, but forgot to
bookmark it and am running crazy now.

I was actually a component that did the following:

You put [image:123] in your text (e.g. Post text) and save it.

When you're reading the data out, you do $post['Post']['text'] = $this-
>Component->parse($post['Post']['text']);

And it automatically replaces [image:123] with the exact path like


If anyone has seen this in action or has an idea how to replicate this
behavior, please reply :-)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Need a bit of help with the delete function

2009-09-06 Thread Whitty

Hi,

I've just started using cakephp, and I'm working on a small program, I
have an existing db which has a table ID  called name_id

but I'm unable to delete records from the table using this id using
the delete function

here is an example of the code:

this is the function:

function delete($id) {
$this->Fullname->delete($id);
$this->Session->setFlash('The name with id: '.$id.' has been
deleted.');
$this->redirect(array('action'=>'index'));
}

and the calling code:

$html->link('Delete', array('action' => 'delete', 'name_id' =>
$fullname['Fullname']['name_id']), null, 'Are you sure?' )

I'm getting Missing argument 1 for FullNamesController::delete()


in the url I'm seeing "delete/name_id:36", how do I get this function
to work, I dont want to change the id as the db I use depends on an
existing program?

Thanks in advance, Darren

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