# |
Aug 9th 2008, 04:44 |
ichsan |
bya |
# |
Aug 9th 2008, 04:44 |
ichsan |
kalileo: thanks for your patient answering my question |
# |
Aug 9th 2008, 04:43 |
ichsan |
Ok, I that's fine. So that's how the CakePHP handle the second line. |
# |
Aug 9th 2008, 04:42 |
kalileo |
ichsan: $this->Medicine->get_current_stock('xobile'); |
# |
Aug 9th 2008, 04:42 |
ichsan |
Because, I already working on this instance of medicine, not that one |
# |
Aug 9th 2008, 04:42 |
ichsan |
kalileo: That gives me advantage because I hate to care about id. |
# |
Aug 9th 2008, 04:41 |
ichsan |
So, there is no way to implement the second line of my code snippet above other than using $this->Medicine->get_current_stock(4) ? |
# |
Aug 9th 2008, 04:41 |
kalileo |
ichsan: I just don't see why that would give you any advantage |
# |
Aug 9th 2008, 04:40 |
kalileo |
but that would be bypassing the cake functionality |
# |
Aug 9th 2008, 04:39 |
kalileo |
as you said at the beginning, you can instantaite a class using $xobile = new med... |
# |
Aug 9th 2008, 04:39 |
ichsan |
CakePHP can handle the first line by doing $this->Medicine->find(4) |
# |
Aug 9th 2008, 04:38 |
ichsan |
But how about the second one? |
# |
Aug 9th 2008, 04:38 |
ichsan |
I know CakePHP can do the first line |
# |
Aug 9th 2008, 04:38 |
ichsan |
$xobile->get_current_stock(); |
# |
Aug 9th 2008, 04:38 |
ichsan |
$xobile = Medicine->find_by_id(4); |
# |
Aug 9th 2008, 04:37 |
ichsan |
Is there any specific technique in CakePHP in handling Class method and an instance of a Class method? Like here in basic PHP |
# |
Aug 9th 2008, 04:36 |
ddeerrrick |
I bet this gets asked a lot, but I'm having a bit of a time trying to get cake functioning as my document root on my mediatemple gs server. I've tried to find a solution online but nothing has worked yet. If anyone has some insight it'd be appreciated |
# |
Aug 9th 2008, 04:35 |
kalileo |
ichsan: yeah, lol, I think I still don't know hwat you're after |
# |
Aug 9th 2008, 04:35 |
ichsan |
No no no, you don't get what I mean |
# |
Aug 9th 2008, 04:34 |
ichsan |
that's how CakePHP handles concept of Class |
# |
Aug 9th 2008, 04:34 |
kalileo |
if you wanna write code specific for just one medicine, you could always create a Xobile Model, and have that extend the medicine model |
# |
Aug 9th 2008, 04:33 |
ichsan |
it resembles class of Medicine |
# |
Aug 9th 2008, 04:33 |
ichsan |
kalileo: I know $this->Medicine is actually an instance. But it is in PHP not as programming concept |
# |
Aug 9th 2008, 04:32 |
kalileo |
but not in this case |
# |
Aug 9th 2008, 04:32 |
kalileo |
there are class methods used in cake too, such as App::import |
# |
Aug 9th 2008, 04:31 |
kalileo |
ichsan: it is an instance already, and you access it using $this->Medicine |
# |
Aug 9th 2008, 04:31 |
ichsan |
kalileo: I know. |
# |
Aug 9th 2008, 04:30 |
kalileo |
you wouldn't have Medicine::get_stock(4) in cake |
# |
Aug 9th 2008, 04:30 |
ichsan |
We are on xobile medicine. |
# |
Aug 9th 2008, 04:30 |
ichsan |
because, I've already working on an instance. |
# |
Aug 9th 2008, 04:30 |
ichsan |
I don't need to remember the id all the times |
# |
Aug 9th 2008, 04:29 |
ichsan |
kalileo: But calling method on an instance is simpler than on a class. Medicine::get_stock_of(4) vs medicine->get_stock(); |
# |
Aug 9th 2008, 04:26 |
kalileo |
ichsan: which is what I would prefer becasue i can use one piece of code for whatever medicine |
# |
Aug 9th 2008, 04:26 |
kalileo |
ichsan: yes, correct |
# |
Aug 9th 2008, 04:26 |
ichsan |
$this->Medicine->current_stock(4); |
# |
Aug 9th 2008, 04:25 |
ichsan |
kalileo: That is static in my opinion. Because I have to supply xobile's id to get current_stock |
# |
Aug 9th 2008, 04:24 |
kalileo |
ichsan: what's static with $this->Medicine->method? |
# |
Aug 9th 2008, 04:24 |
ichsan |
kalileo: My medicine has many behaviours |
# |
Aug 9th 2008, 04:24 |
kalileo |
ichsan: if you need specific subclasses for different kinds of medicine, then you can always extend the medicine call |
# |
Aug 9th 2008, 04:24 |
ichsan |
kalileo: As, I just don't like static method too much. So, may be I can find instance method to handle this medicine problem |
# |
Aug 9th 2008, 04:21 |
kalileo |
ichsan: yeah, remember. you could do all which php class support allows, but why would you want to? |