I built something real quick a short while ago. It does basic joins
using syntax similar to Containable and other model definitions. It
has not been tested or taken to its limits at all. It just does what I
needed at the time but there is room to expand on it.
If any of you are interested in
Cake defaults to AND but you can specify any hierarchy of AND and OR
or AND or OR... until you get dizzy in the head :)
Your search could probably be formatted like:
'conditions' = array(
'Model.is_active' = 'Y',
'or' = array(
'Model.column1 LIKE' = '%keyword%',
I agree with Brian. Using exit is bad style (if you care) disabling
rendering is nicer and lets Cake clean up after the controller has
run.
Your code looks ok. It should display (or force-download) a file for
you. If you see crap, or nothing at all, than check that $type really
is a mime-type
://rsstalker.com/feed/amazon/25percent
-Matthttp://www.pseudocoder.com
On Mar 17, 5:14 am, Martin Westin martin.westin...@gmail.com wrote:
I am trying to put together a feed containing images in the
description of each item along with some p tags and other simple html.
Just entering the html
I'd say this depends on the scenario:
If you created the file your best place is probably the vendors
folder.
If a user uploads it, I keep it in app/uploads/meaningful_folder_name.
If is is uploaded, parsed and then not needed then I'll keep it in tmp
and then delete it when I am done.
If it
This is for only a single model?
In that case you can put the if-clause in the constructor.
function __construct($id = false, $table = null, $ds = null) {
if ( should use special config ) {
$this-useDbConfig = 'special_config';
}
parent::__construct($id, $table, $ds);
}
Richard is right.
Describe does just that... describes the tables so that Cake can know
that Article should have a tltle field and that it contains up to 255
characters and so on and so on...
As Richard also writes this is cached but when you are in debug-mode
you are expected to alter the
The slightly nerdier, but fully dynamic way to check if you are on the
home page (site root).
if ( $html-url('/') == $this-here ) {
// you are on the homepage
}
This will continue to work if you change your routing so that the
index moves from say the posts controller to a brand new
Don't use empty strings for conditions. Use empty arrays. This might
possibly cause your problem since it will find all records for you. At
least it used to in the pre-release versions of 1.2.
Also about recursive: recursive 0 loads belongsTo data. Setting
recursive -1 will load only the primary
] = ...
)
... no [BaseImages] key
PS: sorry for my english
On 11 мар, 18:04, Martin Westin martin.westin...@gmail.com wrote:
You probably want a little, slightly obscure, gem called joins.
In use it looks something like:
$this-find('all', array(
'conditions' = $conditions,
'joins' = array
I, for one, would have expected something more like what is shown
here:
http://book.cakephp.org/view/303/File-Fields
You didn't forget to make the form an upload form?
$form-create('UserInfo', array('type' = 'file'));
On Mar 12, 9:14 am, AD7six andydawso...@gmail.com wrote:
On Mar 12, 7:08
Hi,
I have a few comments:
You should not have to mess with set_include_path at all.
You never assign the controller to the $controller property. You
assign it to $this-data for some reason.
Even if you change that so that $this-controller is the controller
you don't do database calls to
+1 for your version 2 (Fat Model). It is the way I do things for
similar cases.
Sometimes you want to do it beforeSave (this model should be saved
only if the other model can be created)
and other times afterSave when things are the other way around.
afterSave has a helpful parameter so you can
Ah, thought it looked strange. Haven't looked at that variable since
2006 probably :)
On Mar 12, 9:58 am, AD7six andydawso...@gmail.com wrote:
On Mar 12, 9:43 am, Martin Westin martin.westin...@gmail.com wrote:
I, for one, would have expected something more like what is shown
here:http
I'd say that your server is doing things correctly and your local
setup is acting strange. To get any arguments to persist when
paginator creates it's links you need to do this in your view:
$paginator-options(array('url' = $this-passedArgs));
Since you mention nothing about it my guess is
Or is their any facility in cakephp like, i enter only English
information and it is saved in both language.
The developers working on the Cake core are smart, but don't hold your
breath :)
What you are aiming for is two different things.
1. Translations of your application's static texts.
I don't understand the problem at all.
If you have done no redirects you would get:
The action fu renders the view fu.
The view fu contains a form pointing to the action save.
The action save processes the form and renders the view save.
To have the action save returning control to edit of fu
You probably want a little, slightly obscure, gem called joins.
In use it looks something like:
$this-find('all', array(
'conditions' = $conditions,
'joins' = array(
array(
'table' = 'model2',
'alias' = 'Model2',
'type' = 'inner',
I can't remember ever seeing a definite answer as to why this is or
how to fix it... the popular way seems to be to stop using xampp and
try WAMP instead or some of those other fake-linux setups.
If you are the curious type:
The problem should be with some less common WinXP settings and Cake
Unimaginative standard answers: :)
You can try to see if the task you need performed by the other
controller could be put into a model. Most of the real work should be
done by models.
You can also try to make a Component out of that code you need to
call.
The last resort or a quick and dirty
Doing something like this:
$ctrlObject = ClassRegistry::init('MyController');
would get you an instance, only probably not a working one with the
model and components and things.
/Martin
On Mar 10, 5:09 pm, persivo_cunha ricky...@gmail.com wrote:
No one of these three ways could solve my
( I'll skip the usual suggestion: to not use requestAction for this
purpose. It has been said too often and I am sure you have read a few
already. )
That does sound strange. I can suggest only one far-fetched things to
look into.
The very unlikely thing that can mess with the models in this way
I think what you want to do is make use of slugs. Your categories are
not set by you in development, right? They are editable by whoever
administers the application, right? In that case, creating manual
routes for each category becomes very messy.
I suggest you look at sluggable behavior.
I have not done it myself, but as I understand it returning javascript
to be executed is just native to ajax. Have a look at the javascript
library you are using to see if anything needs to be configured for it
to work...(prototype has a property called evalScripts) but it should
more or less
Further points:
1. They forgot that PHP4 is also OK ;)
5. The framework is inadequate to create new records in
tables that have only one autoincrement (or serial) field
I read this as being either about a table with a single field (just
the id), or more likely about Cake not liking composite
Hi Mathew,
I can't replicate your problem. I can request using either syntax. Try
to run the tests for the dispatcher and see if they fail. If so, then
your setup may have some strange setting causing problems.
You don't say how the requestAction fails. What is the error you get?
Those lines
When you specify the login you are telling the component that you
will handle the authentication in that method. To make a login fail
from that method you must black-hole the request. Return values
below do nothing but they should imho.
$this-Security-loginOptions = array(
'type'='basic',
. Is the
cake_core_file_map file getting created?
On Feb 20, 2:12 pm, Martin Westin martin.westin...@gmail.com wrote:
No so on my computer, which is why I thought it was strange.
(Mac OS X)
On Feb 20, 5:37 pm, majna majna...@gmail.com wrote:
There is no Not found when debug = 0, after cake_core_file_map file
I don't remember any specific problem updating from RC3. Generally
changes should be mostly things that are a problem in RC3 will be
fixed. There shouldn't be a lot to change, if anything at all. You
should just update the core and test your app. (I imagine you don't
have a lot of automated tests
No need for all that :)
AppController has no methods defined. That is sort of the point of the
application controller... that is is defined in the application. The
one in the core is just an empty placeholder.
On Feb 20, 1:07 pm, luke BAKING barker lukebar...@gmail.com wrote:
I'd be 'Api to.
I think you can create a HABTM onto itself by aliasing. Look at the
full definition of the relationship in the cookbook and you will find
that you can call the related table something other than it's real
name.
I don't really get what you want to achieve. At first glance I think I
would have
I see plenty of not found at debug level 0... which is strange.
If anyone is at all interested, there is a way to optimize this,
tedious and dirty. For example:
in cake/bootstrap.php
//App::import('Core', array('Dispatcher'));
App::import('Core',
SecurityComponent protects you from some hacking attempts.
If your posted form did not have the required security hashes it
protects you by emptying the data.
You can be treated as a hacker if for example:
- You wrote the form by hand without FormHelper.
- You have ajax on the same page.
/Martin
See my answer in the other thread.
On Feb 20, 2:38 pm, amarradi radis...@googlemail.com wrote:
Thanks a lot the was successful but
the reason for updated was that i want to use the Security Component
and i had an error. Like this
No so on my computer, which is why I thought it was strange.
(Mac OS X)
On Feb 20, 5:37 pm, majna majna...@gmail.com wrote:
There is no Not found when debug = 0, after cake_core_file_map file
is created.
Refresh page one more time..
2009/2/20 Martin Westin martin.westin...@gmail.com
haven't had time to dig further than that so, for now, it's been a
bit of a stab in the dark.
On Tue, Feb 17, 2009 at 6:55 AM, Martin Westin
martin.westin...@gmail.com wrote:
Hi,
This is a bit of an odd case. I have a deep association and want to
paginate the farthest model ignoring its
I haven't done this sort of menu and I am not sure I would want to.
You might need to do the following:
Get all controllers by listing the folder (app/controllers) and
pasring the filenames. Dito for any plugins.
You would then have to instantiate each one and call get_ class_
methods() to get
Catchy subject, no? At least it is to the point. :)
So, I want to (re)define where the temp-files go. I would prefer to do
this without modifying the core, but I can't see where. My first true
entry-point into the request-cycle is in bootstrap.php, too late to
define the constant TMP.
Now,
Hello LunarDraco, devils advocate here.
Exactly how much faster would all that be compared to requestAction()?
Unless you see some serious performance gain why bother? (it is only
one cron request every hour? every 5 min?)
On Feb 18, 4:04 pm, LunarDraco mdc...@gmail.com wrote:
If you use
Hi,
This is a bit of an odd case. I have a deep association and want to
paginate the farthest model ignoring its relation to the
intermediate model... As a straight find using containable might
explain the hierarchy:
$this-data = $this-Person-find('first',array(
'conditions' = array(
This has a lot to do with: What is a comment? or more likely: What
should a comment be about?
There is:
Desire to add, modify or remove content - Editing. Which we have in a
moderated form.
Desire to offer usage examples and tricks - Comments (as php.net for
example) -- my interpretation of a
Personally I think that the change to find is one of the bigger
improvements to 1.2. I could never remember the order of the many many
arguments to find and had to look them up at least once a day. Putting
them info an associative array helps me a lot because I don't have to
remember pointless
I have also had varying success using output buffering so I would also
sugger using a shell command that returns the output instead of
printing it. Just to save you any further headache. But ob stuff
should work and I too would be a little interested in knowing of any
dos and don'ts within Cake's
:) Goodluck.
On Feb 12, 5:46 am, Martin Westin martin.westin...@gmail.com wrote:
Sorry for the spam. I'll try to keep this short.
The company I work for is looking for a quality CakePHP developer. We
currently have more work than I have time to complete and this
problem does not look
If you are on that early version of 1.2, it is likely that you have
encountered some bug in the Model/DSO parts of Cake. There are
probably quite a lot of tickets related to those areas of Cake fixed
between then and the release. 1.2 still had a few tings to fix there
when it was into the RCs.
-programming/cakephp/add-rss-fe...
On Feb 12, 6:32 am, Martin Westin martin.westin...@gmail.com wrote:
I am not really an expert on routing, but i'd say that you need to
specify ext = rss like this
Router::connect('/presses/rss', array('controller' = 'presses
You are right... there is not a whole lot to say without a more
information. For now, I'll assume we are talking about a pretty normal
LAMP server? Let's start with what is using 100% cpu? MySQL or PHP?
Also, the conditions you use. Any associations and so on...
If it all works ok on your local
I am not really an expert on routing, but i'd say that you need to
specify ext = rss like this:
Router::connect('/presses/rss', array('controller' = 'presses',
'action' = 'rss_feed',
'ext' = 'rss'
Hi Miles,
One way that works really well is to have a proxy action accepting
the initial search. This action reorganizes the get or post parameters
into named ones and redirects to the real action. It sound a bit
convoluted but it is a pretty common technique that offers a lot of
flexibility
In
Hi,
I am trying to order by a calculation (in a pagination) but my
calculation is being backticked to death. I can't find a way to write
this so that is works.
I have:
var $paginate = array(
'Modelname' = array(
'fields'=array(
'Modelname.id',
.
Try these:
'(Modelname.foreign_id0 AS result)'
'(Modelname.foreign_id0) AS result'
'((Modelname.foreign_id0) AS result)'
'(((Modelname.foreign_id0) AS result))'
One of them _should_ work
hth
grigri
On Feb 11, 11:34 am, Martin Westin martin.westin...@gmail.com wrote:
Hi,
I am
Hi,
I handle something similar using plugins. Each plugin can be an
independent application if you like. What I went for was an
application core that handles the main layout, users and a few
global things. Then each plugin just taps into the part of the core it
needs or keeps to itself. I just
Hi Aidan,
Sorry, but automatic hashing was not a stumbling block for me. I has a
whole set of other issues when first implementing AuthComponent. But
that is hardly relevant. I see lots of questions about authentication
and passwords, too.
There is a simple and exceedingly common was to
to comply
with an existing database of users.
/Martin
On Feb 5, 11:44 am, Martin Westin martin.westin...@gmail.com wrote:
Hi Aidan,
Sorry, but automatic hashing was not a stumbling block for me. I has a
whole set of other issues when first implementing AuthComponent. But
that is hardly
I wouldn't call it normal. I am not sure there is a normal collation.
If you state nothing else MySQL will choose utf8_general_ci so that
would be the default.
Binary collation is the collation for non-lingual text. Every
character counts and order clauses cause them to be ordered by their
I don't think you can decide the direction in that way. Even though
sortDir() has an options parameter and a directions key it looks
for when you use sort() the options do not get passed along to
sortDir()
http://api.cakephp.org/view_source/paginator-helper/#line-163
Auth should hash the password anywhere.
It looks for $this-data['User']['password'] (or whatever you have
changed it to) on every request.
It will not hash $this-data[0]['User']['password'] for example.
You wrote resetPassword controller. A typo right? Otherwise check
that Auth is included in
I don't know if it is the right way... but the beforeFilter would be
the first place to try. I can imagine that not working so instead you
can override the constructor of that one controller and remove the
helper from the helpers array there. At least it worked for modifying
components under Cake
I have been using a modified DBO for MySQL which does the translation
automatically if you write ... AS Modelname__fieldname. I am not
really sure about the downside to using it but it has not given me any
problems with that project that I am aware of.
It is called dbo_mysql_ex and wirrten by
Just found this website in relation to the whole What the Eff is this
git thing I keep hearing about?
http://gitready.com/
On Feb 2, 1:40 pm, Martin Westin martin.westin...@gmail.com wrote:
@leo I know what you mean. That is why, for two years, I stubbornly
kept using SmartSVN, which
I have only had a shallow look at ExtJS but as I see it:
Prototype is a javascript framework with ajax
ExtJS is an Ajax and GUI framework built in javascript
That is: Prototype is used to put some nice ajax on your web-app and
ExtJS is something you build your app in from the start. Using ExtJS
@Sam
I use this to clean my folders before uploading to the production
server (I don't checkout to that server).
cd where/you/have/svn/crap
find ./ -name .svn -exec rm -rf {} \;
/Martin
On Feb 3, 2:34 pm, Sam Sherlock sam.sherl...@gmail.com wrote:
For me Git because complex is better than
It is not as hard as you may think at first. The hard part about this
is figuring out what your language is called. :) There is an ISO
standard for this which can be a bit confusing.
Swedish (my native language) can be called up using:
swe - 3-letter version
sv - 2-letter version for standard
really hate those my-os-is-better, my-framework-is-cooler, my-
browser-is-safer-discussions. everyone should test a few of the
frameworks and use the one that fits his way of developing best.
Rankings can only give you an overview.
On 2 Feb., 14:04, Martin Westin martin.westin...@gmail.com
You can probably do something like this:
1. make a copy of app/webroot/index.php - call it start_cake.php or
something and put it where you can include it.
In that file:
2. alter the include paths to suit your environment so that cake can
be found.
3. remove the call to Dispatcher almost at the
Why do I hear the cries of Jihad every time I read about this vs that
framework :)
If that website is a guide the the best framework, then these are the
very best short films and videos.
http://www.youtube.com/browse?s=trc=0l=b=0
You decide popularity by voting and popular is not always the
Auth does not enforce either case sensitivity or insensitivity. This
is all up to how you have your database configured.
If your database, table of field is set to a _ci collation you will
have case insensitive usernames. If you have a _cs or _bin
collation you will be case sensitive. (All MySQL
I'd say that beforeFind should be used for thing that you want to run
at all times.
Instead of doing this in beforeFind you might want to create a custom
find which is a good way to enforce custom logic to the find operation
while leaving any associations and other internal queries alone.
As a
@leo I know what you mean. That is why, for two years, I stubbornly
kept using SmartSVN, which is free but horrible in comparison. After
trying Cornerstone and smiling with every commit, I gladly paid the
license for Cornerstone... or I should say my employer reluctantly
did :)
The new api (new code all the way) was written by Mark Story and Gwoo.
http://mark-story.com/posts/view/the-new-face-of-cakephp-s-api
Since they just released it a few days ago I imagine there may be a
few minor things to tweak. But I don't see what you describe, at least
not when looking at
Hi vikas,
Getting the value works no different than the value of a normal text
input field.
The controller sees
this-data['Model']['report_timeframe'] // or whatever you call it.
The options array you pass to the select field looks like this:
array(
'value' = 'visible label'
)
So I usually
If you are on Mac OS X you should really look at Versions and
Cornerstone. They are both excellent subversion clients that are very
Mac. I bought Cornerstone after using SmartSVN for a while (read
years) and it's a world of difference, even for something as basic as
versioning code.
Well, if you
In my experience a disabled field will not follow the rest of the
values to the server.
According the the w3c a disabled field cannot be successful which I
read as can not have a value when submitted.
You can use the attribute readonly (only for text inputs) which
disables editing but the value
you for the example with the temp table, I
suspect it will come in handy quite soon.
/Martin
On Jan 26, 7:56 pm, AD7six andydawso...@gmail.com wrote:
On Jan 26, 2:35 pm, Martin Westin martin.westin...@gmail.com wrote:
Hi,
I am in need of an unusual query that I find it hard to search
Thanks RoVo,
I was on that path but stopped when my personal needs ended with the
knowledge that all text is converted on parsing.
But if I want to read an xml file and then save it back out again I
would definitely like to k ow the encoding so that the saved file
would have the same encoding as
Hi Seth,
Check ut this section in the cookbook. I think your problem is that
you specify each radio individually using $form-radio. You might try
$form-input('Field',array('type'='radio','options'=$your_data)) as
it seems to be the promoted way to make a radio group.
Alongside questions about HABTM relationships this is one topic that
never dies. :)
I have said this before. I have no real-life problems with the speed
of CakePHP. I don't know all the other frameworks so there is no way
for me to offer a comparative opinion. But I have applications running
I would probably not go all the way back to a data source. At least
not at first. I would create a special Model that talked to the web
service. The reason is that I don't really think you will end up
supporting a majority of the data source features so it may be more
work than you want. How
There are lots of goodies you can use (for MySQL at least).
Datediff is my preferred comparison since it does not fail on leap-
years and things like that.
DATEDIFF(date1,date2) 0
- true or false
To construct modified versions of today I sometimes use Addate adn
Subdate
ADDDATE(CURDATE(),
The manual entry is short but that is all that is needed for a basic
setup.
Describe commands stop as soon as you go into debug 0.
General performance advice (Not things you do in your app. Things you
do in deployment):
Compiling php and the web server specifically if the added boost is
worth
Hi,
I am in need of an unusual query that I find it hard to search for on
Google or MySQL.com since all the terms I think of are very common
ones. Hopefully someone reading this can guide me in the right
direction.
I have a series of values in an array. I can find out which records
have matching
Hi Jaro,
I am pretty sure you have missed the plugin name when targeting the
Model. I have had a number of hard to track bugs that were related
to the naming of classes in plugins.
If you do debug($this-OrderProduct) You should see OrderProduct
Object... but you will probably see
first takes precedence. If
a bad version is called up first then anything after that makes no
diference.
So check every reference to that model while you are at it.
/martin
On Jan 26, 4:13 pm, Martin Westin martin.westin...@gmail.com wrote:
Hi Jaro,
I am pretty sure you have missed the plugin
There are a two known things I remember reading about:
Ajax (or rapid-fire fingers) conflicting with high security levels.
Setting security to medium or lower should fix that.
There is also the possibility that your host does a bit of clean-up
in php's sessions dir. Using cake sessions should
Thanks RoVo,
That's what I was afraid of. I don't like modifying dist-files, but it
looks like I have to.
Let's just hope nothing changes in index.php for a while :)
/Martin
On Jan 20, 1:16 pm, RoVo rol...@service-itzehoe.de wrote:
Hi Martin,
Unfortunately defining TMP in bootstrap.php is
From http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
(first comment)
SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( `time` ) ) ) AS total_time FROM
time_table;
So you should be able to add a fields to your search where you put
the above MySQL trick. You may also want to add a GROUP
You don't really need to change the location in the source to display
sql debugging in a pretty way.
http://snook.ca/archives/cakephp/debug_styles/
For any debug() statements you put in your code you would have to
override that function and save them all until you get to the layout.
But the
Hi,
This must be something obvious I am missing, so I thought I'd ask.
I load an rss feed:
App::import('Core', 'Xml');
$rss = new XML($url_to_an_rss_feed);
And thought that these would automatically reflect the encoding (and
version for that matter) of the xml loaded:
debug( $rss-encoding );
Hi ReVo,
$__header contains a string of the first line in the xml. this will
usually contain something like
xml version=1.0 encoding=UTF-8
since the tag characters are stripped away. But it may also contain
the whole of, or part of, the xml since xml files are valid without
any whitespace.
, Martin Westin martin.westin...@gmail.com wrote:
Hi ReVo,
$__header contains a string of the first line in the xml. this will
usually contain something like
xml version=1.0 encoding=UTF-8
since the tag characters are stripped away. But it may also contain
the whole of, or part of, the xml since
?
still have same problem.
please can somebody help me?
Thanks
On Jan 20, 2:45 pm, Martin Westin martin.westin...@gmail.com wrote:
I second Mark's reply. If you simply call path/to/cake/console/cake
you will be using the system's version of php.
If you are committed to using a lot
this would
probably help a lot.
/Martin
On Jan 21, 9:19 am, brian bally.z...@gmail.com wrote:
no! That method's private to Model. I meant, have a look through it
(and save) to see what's happening internally.
On Wed, Jan 21, 2009 at 2:41 AM, Martin Westin
martin.westin...@gmail.com wrote
This is not a good day for writing...
Last paragraph should of-course read:
Where does this stuff get tested? I can't find any tests that use
callbacks on joining models in the core tests. Locating where they
test this would probably help a lot.
On Jan 21, 10:50 am, Martin Westin
I have used http://sourceforge.net/projects/phpexcelreader
It is quite basic (and therefore lightweight) but does the trick so
far.
Example from the dist:
$data = new Spreadsheet_Excel_Reader();
$data-read('jxlrwtest.xls');
for ($i = 1; $i = $data-sheets[0]['numRows']; $i++) {
for ($j
Did you create a shell task?
I used to use a method similar to the one described in the bakery
article you link to. But a while back I switched to using a shell task
(less hacking more cake-friendly support).
A very simple shell might just look like this:
class HourlyShell extends Shell {
I second Mark's reply. If you simply call path/to/cake/console/cake
you will be using the system's version of php.
If you are committed to using a lot of shell stuff (such as bake), you
really should switch to using the system's php install. It will make
things easier in the long run. The setup
:
The reason I want to use the save and delete callbacks is that I want
to put together a custom counterCache for a habtm relationship. That
is why I want to trigger an update each time a link is created or
deleted.
/Martin
On Jan 19, 8:56 am, Martin Westin martin.westin...@gmail.com wrote:
Hi there,
I
Hi (again),
I want to try to host one application under several domains.
One Cake
One App
Many configs
Many temp dirs
It is that last bit I get stuck on. I really want to split the tmps so
I have one for each domain. Unfortunately defining TMP in
bootstrap.php is too late. It is already set in
Royle a...@sleekgeek.com.au wrote:
Can you explain why you need different tmp directories for the same
actual app? If it's for caching, etc, maybe you can use a cache prefix
dynamically?
Cheers,
Adam
Martin Westin wrote:
Hi (again),
I want to try to host one application under several
, Jan 20, 2009 at 5:02 AM, Martin Westin
martin.westin...@gmail.com wrote:
bump...
My current working theory is that for some (to me) unknown reason
(performance?) habtm relationships are created and deleted without
fully utilizing the joining model. That is when you do:
$data = array
301 - 400 of 439 matches
Mail list logo