Since HABTM data is constructed as separate SQL statements, and not a JOIN,
you cannot add conditions to the query directly. There are ways to get the
data you want, though. Check out the example in the book[1] or search
Google for cakephp find habtm data
1:
you probably meant
Type hasMany BooksUser...
On 17 Okt., 22:17, Mariano C. mariano.calan...@gmail.com wrote:
I'm studing model associations, I would know if i've understand it
correctly:
I have five tables: users, books, books_users, authors and types.
users, authors and types just have PK
Everything appears to be correct. Try deleting any files in
app/tmp/cache/models/ if you haven't already. And set debug to 2, both
so the models won't be cached and so you can see what queries are
being run.
On Mon, Oct 11, 2010 at 2:04 PM, Ashwani Kumar
ashwani.mail...@gmail.com wrote:
Hi all!
In User model:
var $displayField = 'username';
Then find('list') will return an array as id = username
On Mar 17, 8:50 pm, abocanegra aaronbocane...@gmail.com wrote:
I am trying to learn more about associating through models. My current
issue is that I am attempting to design the post add
Thank you for the response. I was able to get it working finally by
the following code int he postscontroller under the add function.
$users = $this-Post-User-find('list', array('fields' =
array('User.username')));
$this-set(compact('users'));
Thanks
On Mar 17, 7:27 pm, cricket
Take a look in the CakePHP manual at the Containable behaviour, which
will give you the possibility to specify how deep you want to go in
your relationships when retrieving your data.
http://book.cakephp.org/view/474/Containable
Also it will make your life easier :)
Enjoy,
John
On Feb 24,
In the case of viewing a record, Containable is very much your
friend. Saves you so much time.
If paginating deep associations, espcially if you want a condition on
model 3 or 4, then you need to get your head around ad-hoc (forced)
joins.
http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/
Lapinski
ohneworte-2 wrote:
Hello Together,
I want to link two Models without using a Foreign Key, but using some
Conditions instead. Here is my example:
Model:
-
class Category extends AppModel {
Here are some of the table fields. it's the table USER, GROUPS and MEDICIANL
DEVICE.
In short relatons are: ser should be in one group and have many MedDevice,
group should have one user, medicinal
device should have only one user.
CREATE TABLE IF NOT EXISTS `baza2`.`USER` (
`id` INT NOT NULL
The database table names ought to be plural, viz: MEDICINAL_DEVICES,
USERS etc. Cake is intelligent enough to handle plurals such as
COMPANIES (COMPANY).
In the model definitions, the model will be the capitalised singular
version of the tablename, e.g. User
Foreign keys are singular, e.g.
Tables are supposed to be plural (users,groups,medicinal_devices) and the
foreign keys singular(user_id,group_id...)
Change it and give it another shot =)
2009/7/17 Zoran Kovac zoko2...@gmail.com
Here are some of the table fields. it's the table USER, GROUPS and
MEDICIANL DEVICE.
In short
Aargh...name conventions, still not used to it. Thanks for the heads up,
knew it had to be something obvoius. It always is ;))
Now it works like a charm.
--
Zoran Kovac
091/ 588 6175
V.Gorica
On Fri, Jul 17, 2009 at 9:53 AM, Carlos Lavin carloslavi...@gmail.comwrote:
Tables are supposed to
Maybe if you described the tables' fields.. theres gotta be some convention
breaking there
2009/7/16 Zoran Kovac zoko2...@gmail.com
Hi!
I'm having a dilema, maybe the better word is that I'm puzzled.
The problem is when I'm baking models. The console doesn't detect
relations between
Start from the AccountAlert model rather than the Alert model. Use
contain as well.
$alert_ids = $this-AccountAlert-find (
'all',
array (
'contain' = array(),
'conditions'= array (
'AccountAlert.account_id' =
On Apr 25, 9:55 am, James K james.m.k...@gmail.com wrote:
Start from the AccountAlert model rather than the Alert model. Use
contain as well.
$alert_ids = $this-AccountAlert-find (
'all',
array (
'contain' = array(),
'conditions' =
In cases like what you are looking at it tends to work a bit better if
you rather do the find on the model you want to filter.
Something like:
$alert_ids = $this-Alert-AccountAlert-find (
'all',
array (
'conditions'= array (
var $hasmany = array('People', 'Post', 'Tag);
On Dec 26, 11:51 am, mona poojapinj...@gmail.com wrote:
How to make association between three of four tables because i m
fetching data on my table from three different tables
--~--~-~--~~~---~--~~
You received this
You can create the column stock in the association table.In the form where
you do the association, you can add a new field for the stock.
At least that was what i understood from your question...
Regards,
Luiz Poleto
2008/9/17 VitillO [EMAIL PROTECTED]
Hi, i have the following structure for
You can create a model for your habtm association so you can add extra
fields, etc, using the with key. Something like this...
class Product extends AppModel {
...
var $hasAndBelongsToMany = array(
'Size' = array('className' = 'Size',
'with' = 'ProductsSize', // -- this here, class
Hi guys, thanks for your replies.
Right now, im my 'add' view of products, im getting a multiple select
for the sizes, where i can select which sizes are available for that
particular product, thats fine. The problem is that i need a stock
number for each of this available sizes, so a multiple
I explain how with work here, I think this should be good to get
you started:
http://teknoid.wordpress.com/2008/07/03/notes-on-cakephp-habtm-part-1-the-basics/
Also, just a hint... cake can easily create checkboxes for you
(instead of multi-select).
Just tell it to use 'multiple'='checkbox' in
Ok guys, it seems i have the data (extra field 'stock' in the
association table) in $this-data when i edit a Product, something
like this, so the association table is auto-modelized:
[Size] = Array
(
[0] = Array
(
[id] = 2
I always remember it like this:
If a table contains a foreign key, it's like a little label that
another object has put on it... i.e. it belongsTo something else.
hth/fwiw,
John
On Jul 3, 2008, at 1:38 PM, Jonathan Snook wrote:
A priority hasMany tasks.
A task belongsTo a priority.
@Jonathan, yes it always a bit confusing the hasOne (in Cake)..
because a Task hasOne priority, no matter if this priority is
shared .. but for cake it'a a belongsTo .. :-) Even after using for
few months (years)... hasOne always make me think twice (actually I
use it very rarely)..
On Jul 3,
I've done the following:
Clipranking Model:
function findClipByRank($site_id){
return $this-query(SELECT Clipranking.rank,
Clipranking.site_id,
Clipranking.required, Clip.id, Clip.name, Clip.length FROM
cliprankings AS Clipranking, clips AS Clip WHERE Clipranking.site_id =
It's 1.19 btw... but think that won't mather much.
On Feb 6, 10:16 am, Bo-oz [EMAIL PROTECTED] wrote:
Hi,
I would like to enrich a model with data from another model. However
they are not directly related. The value that needs to be fetched from
the other model lies within a certain
I was afraid of that... I've read some other reply's by you in another
thread, and based on that, I was already expecting that this could not
be done. Would be great functionality though.
On Feb 6, 10:37 am, AD7six [EMAIL PROTECTED] wrote:
On Feb 6, 10:23 am, Bo-oz [EMAIL PROTECTED] wrote:
On Feb 6, 10:23 am, Bo-oz [EMAIL PROTECTED] wrote:
It's 1.19 btw... but think that won't mather much.
I think you need (a v recent) 1.2 for that to work unless you do it
yourself
hth,
AD
--~--~-~--~~~---~--~~
You received this message because you are
This does also tend to be related to my post on naming conventions in
http://groups.google.com/group/cake-php/browse_thread/thread/35318b04d8a93144/fcffe0e17499f82c?lnk=stq=#fcffe0e17499f82c
if the class name and the $name value are to be the same, why is this
not the case with Controllers? Is
Did you try turning on debug mode and see how the SQL statement looks
like? Try running the sql statement manually and you should be able to
track where the problem is.
Zonium
On Dec 7, 5:30 pm, sanderken [EMAIL PROTECTED] wrote:
People looking for the answer to defining limit row in oracle
People looking for the answer to defining limit row in oracle :
in the model , use the
'conditions' = ' WHERE ROWNUM = 3 '
option.
Limit is the implementation in mySQL.
Hope this helps someone...
On 8 dec, 01:53, sanderken [EMAIL PROTECTED] wrote:
Maybe I should mention I'm using
Maybe I should mention I'm using oracle for DBMS.
On 7 dec, 21:54, sanderken [EMAIL PROTECTED] wrote:
Hey,
I defined a user (named Gebruiker in my native language ) model
where when I call a $this-find() , needs to retrieve only a limited
amount of related information.
When I add the
Maybe this can help you:
http://wiki.cakephp.org/docs:understanding_associations
--~--~-~--~~~---~--~~
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
Hi Brian,
You can´t create 2 associations with the same name. You can't say a
user HasOne Venue and User HABTM Venue - if you don´t give you
associations unique names the data for both will get mixed together
(with confusing results as you have seen).
Let me clarify what that means before you
Thank you! That fixed my problem perfectly!
AD7six wrote:
Hi Brian,
You can´t create 2 associations with the same name. You can't say a
user HasOne Venue and User HABTM Venue - if you don´t give you
associations unique names the data for both will get mixed together
(with confusing results
Could someone help me with this?
Brian French wrote:
I should have elaborated more. When you view that link then go to view a
particular user:
http://www.myclubbersguide.com/users/view/6
The associations dont seem to be working and i am now getting a php error.
(i have a view method in
bump
Brian French wrote:
I am having trouble associating the multiple models i have with each other.
I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'.
The 'User' also hasAndBelongsToMany of the same ones (like he can
subscribe to them as well as be one/all of them).
I am
On 9/8/06, Brian French [EMAIL PROTECTED] wrote:
I am having trouble associating the multiple models i have with each other.
I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'.
The 'User' also hasAndBelongsToMany of the same ones (like he can
subscribe to them as well as be
Scaffolding can display this for you, it's a great tool!
You can view the output here: http://www.myclubbersguide.com/users
It contains the queries being used as well as the print_r() of the
object(s).
The code for the models was in the first email/post in this thread. As
far as i understand
Hi Brian,
I took a peek at your link: I don´t quite understand what the problem
is, can you elaborate?
The sql at the foot of the page shows that sql queries are being
executed for your associations. If you look at the user test you can
see that there are results for each association type.
I should have elaborated more. When you view that link then go to view a
particular user:
http://www.myclubbersguide.com/users/view/6
The associations dont seem to be working and i am now getting a php error.
(i have a view method in the users controller, but i commented it out so
the
I'm having a similar problem simply trying to add comments to posts.
I've tried to get a list of comments that would be associated with a
single post by adding
$this-set('comments', $this-Comment-findAll(WHERE post_id =
'$id'));
to the view() function under posts_controller.php but that line
Gotta use model assocations - it makes this sort of thing so much nicer.
http://manual.cakephp.org/chapter/6
Looks like your Comment belongsTo Post, and probably Post hasMany
Comment.
Give the manual a look, and let me know if you have questions on it.
-- J
On May 9, 2006, at 1:47 PM,
I read through the manual in one go last week, totally forgot I had to
set up the associations myself.
Now that I've done it I can't believe how simple it is. I'm REALLY
starting to like this whole baking thing. Thanks John!
--~--~-~--~~~---~--~~
You received
44 matches
Mail list logo