Saturday, December 31, 2011

Re: Year range 1991-2031

I am not sure if I understand your question exactly, but it looks like the date range for the select list allow for the dates that you need.


If this is the problem, then you can controller the date range by specifying a mindate, or maxdate in the Form select options 

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: How to "custom belongsto" in CakePHP 2?

BelongsTo is simply a left join, (on the retrieval side)...

I think what you are looking for is the Relationship conditions option. (Which will create the ON statement in SQL)

So what you want is something that looks like...

Radpostauth Model...

var $belongsTo = array(
'Wdevice' => array(
'className' => 'Wdevice',
'foreignKey' => false,
'conditions' => array(
 Wdevice.device_mac = radpostauth.username
)
);

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Multiple Businesses in one database

I do a very similar thing to allow users multiple profiles. So they can segregate their data by company, or family, or team.

Here is the basic logic.

In the appController beforeFilter() method set the logged in user to the appModel class that you are fetching. Such as...
AppModel::setActiveUser($this->Auth->user());

Of course you will need to set up a static property in the AppModel. Such as...
public static $activeUser;
public static function setActiveUser($appUser){
self::$activeUser = $appUser;
}

Once you do this, any model that is based on multi-business logic, will have access to the current logged in user.

Now, in your Events model, you could add the following code... (or something similar)
function beforeFind($qd){
if(isset(parent::$activeUser['User']['business_id'])){
$qd['conditions'][] = array(
'Event.business_id '=> parent::$activeUser['User']['business_id']
 );
}
return $qd;
}


If you want to do a much simpler method...
You can simply add a condition to the paginate options in the controller index method.
$appUser = $this->Auth->user();
$this->paginate['conditions'][] = array('Event.business_id' => $appUser['User']['business_id']);

Happy Coding!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

My last guess is pdo mysql is not enabled.

2012/1/1 Renato de Freitas Freire <renatoff@gmail.com>:
> I had the same problem when start using cake 2.0.4 on my work, but I tried
> it on my pc and it work fine.
>
> It might be something with your server configuration.
>
> I will doble check it on monday on my work.
> Any news I tell you.
>
> But you can try it on other server, or try to upgrade your mysql, or
> something like that.
>
> --
> Renato Freire
>
>
>
>
> 2012/1/1 Ronghua <ronghuazhao@gmail.com>
>>
>> Yes, I grant all privileges to the user. Actually, if I write a php
>> file to connect to mysql directly, I can query the result from table.
>>
>> <?php
>> $host='localhost';
>> $user_name='testuser';
>> $password='123456'; //这里****是你设置的密码
>>
>> $conn=mysql_connect($host,$user_name,$password);
>> if (!$conn)
>> {
>> die('connect fail:'.mysql_error());
>> }
>> echo 'connect success!<br/>';
>> mysql_select_db("cake_testing", $conn);
>> $result = mysql_query("SELECT * FROM test");
>> while($row = mysql_fetch_array($result))
>> {
>> echo $row['ref']." ".$row['content'];
>> echo "<br />";
>> }
>> if (mysql_close($conn))
>> {
>> echo '<br/>...<br/>';
>> echo '到数据库的连接已经成功关闭';
>> }
>> ?>
>>
>> On 1月1日, 上午10时39分, 清水�己 <hiromi2...@gmail.com> wrote:
>> > Did you have done GRANT it?
>> >
>> > 2012/1/1 Ronghua <ronghuaz...@gmail.com>:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > I also tried my root login configuration, but it doesn't work as well.
>> >
>> > > On 1月1日, 上午1时51分, "Timothy O'Reilly" <timothy.john.orei...@gmail.com>
>> > > wrote:
>> > >> I'm sure you have tried it, but have you tried Login "Root" and
>> > >> Password
>> > >> "Root"?
>> > >> Regards,
>> > >> Tim
>> >
>> > >> On Sat, Dec 31, 2011 at 2:59 AM, Ronghua <ronghuaz...@gmail.com>
>> > >> wrote:
>> > >> > Hi, today is first day I'm using cake. I have setup CakePHP 2.0.4.
>> > >> > In
>> > >> > \app\Config\database.php, the configuration is as below
>> > >> > <?php
>> >
>> > >> > class DATABASE_CONFIG {
>> > >> > public $default = array(
>> > >> > 'datasource' => 'Database/Mysql',
>> > >> > 'persistent' => false,
>> > >> > 'host' => 'localhost',
>> > >> > 'login' => 'testuser',
>> > >> > 'password' => '123456',
>> > >> > 'database' => '',
>> > >> > 'prefix' => '',
>> > >> > 'encoding' => ''
>> > >> > );
>> > >> > }
>> >
>> > >> > I can connect to mysql with MySQLQueryBrowser by testuser and pwd
>> > >> > 123456, but I can't connect to database through Cake. Here is the
>> > >> > description in the website. Can someone help me here? From the
>> > >> > website
>> > >> > reference, seems nothing else need to change.
>> >
>> > >> > Your version of PHP is 5.2.6 or higher.
>> >
>> > >> > Your tmp directory is writable.
>> >
>> > >> > The FileEngine is being used for caching. To change the config edit
>> > >> > APP/Config/core.php
>> >
>> > >> > Your database configuration file is present.
>> >
>> > >> > Cake is NOT able to connect to the database.
>> >
>> > >> > --
>> > >> > Our newest site for the community: CakePHP Video Tutorials
>> > >> >http://tv.cakephp.org
>> > >> > Check out the new CakePHP Questions
>> > >> > sitehttp://ask.cakephp.organdhelp
>> > >> > others with their CakePHP related questions.
>> >
>> > >> > To unsubscribe from this group, send email to
>> > >> > cake-php+unsubscribe@googlegroups.com For more options, visit this
>> > >> > group
>> > >> > athttp://groups.google.com/group/cake-php
>> >
>> > > --
>> > > Our newest site for the community: CakePHP Video
>> > > Tutorialshttp://tv.cakephp.org
>> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
>> > > others with their CakePHP related questions.
>> >
>> > > To unsubscribe from this group, send email to
>> > > cake-php+unsubscribe@googlegroups.com For more options, visit this
>> > > group athttp://groups.google.com/group/cake-php
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> cake-php+unsubscribe@googlegroups.com For more options, visit this group
>> at http://groups.google.com/group/cake-php
>
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

I had the same problem when start using cake 2.0.4 on my work, but I tried it on my pc and it work fine.

It might be something with your server configuration.

I will doble check it on monday on my work.
Any news I tell you.

But you can try it on other server, or try to upgrade your mysql, or something like that.

--
Renato Freire




2012/1/1 Ronghua <ronghuazhao@gmail.com>
Yes, I grant all privileges to the user. Actually, if I write a php
file to connect to mysql directly, I can query the result from table.

<?php
$host='localhost';
$user_name='testuser';
$password='123456'; //这里****是你设置的密码

$conn=mysql_connect($host,$user_name,$password);
if (!$conn)
{
die('connect fail:'.mysql_error());
}
echo 'connect success!<br/>';
mysql_select_db("cake_testing", $conn);
$result = mysql_query("SELECT * FROM test");
while($row = mysql_fetch_array($result))
{
echo $row['ref']." ".$row['content'];
echo "<br />";
}
if (mysql_close($conn))
{
echo '<br/>...<br/>';
echo '到数据库的连接已经成功关闭';
}
?>

On 1月1日, 上午10时39分, 清水�己 <hiromi2...@gmail.com> wrote:
> Did you have done GRANT it?
>
> 2012/1/1 Ronghua <ronghuaz...@gmail.com>:
>
>
>
>
>
>
>
> > I also tried my root login configuration, but it doesn't work as well.
>
> > On 1月1日, 上午1时51分, "Timothy O'Reilly" <timothy.john.orei...@gmail.com>
> > wrote:
> >> I'm sure you have tried it, but have you tried Login "Root" and Password
> >> "Root"?
> >> Regards,
> >> Tim
>
> >> On Sat, Dec 31, 2011 at 2:59 AM, Ronghua <ronghuaz...@gmail.com> wrote:
> >> > Hi, today is first day I'm using cake. I have setup CakePHP 2.0.4. In
> >> > \app\Config\database.php, the configuration is as below
> >> > <?php
>
> >> > class DATABASE_CONFIG {
> >> >        public $default = array(
> >> >            'datasource' => 'Database/Mysql',
> >> >            'persistent' => false,
> >> >            'host' => 'localhost',
> >> >            'login' => 'testuser',
> >> >            'password' => '123456',
> >> >            'database' => '',
> >> >            'prefix' => '',
> >> >            'encoding' => ''
> >> >        );
> >> > }
>
> >> > I can connect to mysql with MySQLQueryBrowser by testuser and pwd
> >> > 123456, but I can't connect to database through Cake. Here is the
> >> > description in the website. Can someone help me here? From the website
> >> > reference, seems nothing else need to change.
>
> >> > Your version of PHP is 5.2.6 or higher.
>
> >> > Your tmp directory is writable.
>
> >> > The FileEngine is being used for caching. To change the config edit
> >> > APP/Config/core.php
>
> >> > Your database configuration file is present.
>
> >> > Cake is NOT able to connect to the database.
>
> >> > --
> >> > Our newest site for the community: CakePHP Video Tutorials
> >> >http://tv.cakephp.org
> >> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> >> > others with their CakePHP related questions.
>
> >> > To unsubscribe from this group, send email to
> >> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> >> > athttp://groups.google.com/group/cake-php
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

Yes, I grant all privileges to the user. Actually, if I write a php
file to connect to mysql directly, I can query the result from table.

<?php
$host='localhost';
$user_name='testuser';
$password='123456'; //这里****是你设置的密码

$conn=mysql_connect($host,$user_name,$password);
if (!$conn)
{
die('connect fail:'.mysql_error());
}
echo 'connect success!<br/>';
mysql_select_db("cake_testing", $conn);
$result = mysql_query("SELECT * FROM test");
while($row = mysql_fetch_array($result))
{
echo $row['ref']." ".$row['content'];
echo "<br />";
}
if (mysql_close($conn))
{
echo '<br/>...<br/>';
echo '到数据库的连接已经成功关闭';
}
?>

On 1月1日, 上午10时39分, 清水�己 <hiromi2...@gmail.com> wrote:
> Did you have done GRANT it?
>
> 2012/1/1 Ronghua <ronghuaz...@gmail.com>:
>
>
>
>
>
>
>
> > I also tried my root login configuration, but it doesn't work as well.
>
> > On 1月1日, 上午1时51分, "Timothy O'Reilly" <timothy.john.orei...@gmail.com>
> > wrote:
> >> I'm sure you have tried it, but have you tried Login "Root" and Password
> >> "Root"?
> >> Regards,
> >> Tim
>
> >> On Sat, Dec 31, 2011 at 2:59 AM, Ronghua <ronghuaz...@gmail.com> wrote:
> >> > Hi, today is first day I'm using cake. I have setup CakePHP 2.0.4. In
> >> > \app\Config\database.php, the configuration is as below
> >> > <?php
>
> >> > class DATABASE_CONFIG {
> >> > public $default = array(
> >> > 'datasource' => 'Database/Mysql',
> >> > 'persistent' => false,
> >> > 'host' => 'localhost',
> >> > 'login' => 'testuser',
> >> > 'password' => '123456',
> >> > 'database' => '',
> >> > 'prefix' => '',
> >> > 'encoding' => ''
> >> > );
> >> > }
>
> >> > I can connect to mysql with MySQLQueryBrowser by testuser and pwd
> >> > 123456, but I can't connect to database through Cake. Here is the
> >> > description in the website. Can someone help me here? From the website
> >> > reference, seems nothing else need to change.
>
> >> > Your version of PHP is 5.2.6 or higher.
>
> >> > Your tmp directory is writable.
>
> >> > The FileEngine is being used for caching. To change the config edit
> >> > APP/Config/core.php
>
> >> > Your database configuration file is present.
>
> >> > Cake is NOT able to connect to the database.
>
> >> > --
> >> > Our newest site for the community: CakePHP Video Tutorials
> >> >http://tv.cakephp.org
> >> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> >> > others with their CakePHP related questions.
>
> >> > To unsubscribe from this group, send email to
> >> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> >> > athttp://groups.google.com/group/cake-php
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

Did you have done GRANT it?

2012/1/1 Ronghua <ronghuazhao@gmail.com>:
> I also tried my root login configuration, but it doesn't work as well.
>
> On 1月1日, 上午1时51分, "Timothy O'Reilly" <timothy.john.orei...@gmail.com>
> wrote:
>> I'm sure you have tried it, but have you tried Login "Root" and Password
>> "Root"?
>> Regards,
>> Tim
>>
>>
>>
>>
>>
>>
>>
>> On Sat, Dec 31, 2011 at 2:59 AM, Ronghua <ronghuaz...@gmail.com> wrote:
>> > Hi, today is first day I'm using cake. I have setup CakePHP 2.0.4. In
>> > \app\Config\database.php, the configuration is as below
>> > <?php
>>
>> > class DATABASE_CONFIG {
>> > public $default = array(
>> > 'datasource' => 'Database/Mysql',
>> > 'persistent' => false,
>> > 'host' => 'localhost',
>> > 'login' => 'testuser',
>> > 'password' => '123456',
>> > 'database' => '',
>> > 'prefix' => '',
>> > 'encoding' => ''
>> > );
>> > }
>>
>> > I can connect to mysql with MySQLQueryBrowser by testuser and pwd
>> > 123456, but I can't connect to database through Cake. Here is the
>> > description in the website. Can someone help me here? From the website
>> > reference, seems nothing else need to change.
>>
>> > Your version of PHP is 5.2.6 or higher.
>>
>> > Your tmp directory is writable.
>>
>> > The FileEngine is being used for caching. To change the config edit
>> > APP/Config/core.php
>>
>> > Your database configuration file is present.
>>
>> > Cake is NOT able to connect to the database.
>>
>> > --
>> > Our newest site for the community: CakePHP Video Tutorials
>> >http://tv.cakephp.org
>> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
>> > others with their CakePHP related questions.
>>
>> > To unsubscribe from this group, send email to
>> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
>> > athttp://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

I also tried my root login configuration, but it doesn't work as well.

On 1月1日, 上午1时51分, "Timothy O'Reilly" <timothy.john.orei...@gmail.com>
wrote:
> I'm sure you have tried it, but have you tried Login "Root" and Password
> "Root"?
> Regards,
> Tim
>
>
>
>
>
>
>
> On Sat, Dec 31, 2011 at 2:59 AM, Ronghua <ronghuaz...@gmail.com> wrote:
> > Hi, today is first day I'm using cake. I have setup CakePHP 2.0.4. In
> > \app\Config\database.php, the configuration is as below
> > <?php
>
> > class DATABASE_CONFIG {
> >        public $default = array(
> >            'datasource' => 'Database/Mysql',
> >            'persistent' => false,
> >            'host' => 'localhost',
> >            'login' => 'testuser',
> >            'password' => '123456',
> >            'database' => '',
> >            'prefix' => '',
> >            'encoding' => ''
> >        );
> > }
>
> > I can connect to mysql with MySQLQueryBrowser by testuser and pwd
> > 123456, but I can't connect to database through Cake. Here is the
> > description in the website. Can someone help me here? From the website
> > reference, seems nothing else need to change.
>
> > Your version of PHP is 5.2.6 or higher.
>
> > Your tmp directory is writable.
>
> > The FileEngine is being used for caching. To change the config edit
> > APP/Config/core.php
>
> > Your database configuration file is present.
>
> > Cake is NOT able to connect to the database.
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

I tried this as well, created database as you mentioned below with
testuser, change the configure file as below. But the result is same
as below, still can't connect to DB.
<?php
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'testuser',
'password' => '123456',
'database' => 'cake_testing',
'prefix' => '',
'encoding' => ''
);
}

On 1月1日, 上午1时49分, Sam Sherlock <sam.sherl...@gmail.com> wrote:
> because this is blank
>
> 'database' => '',
>
> what is the name of the mysql database your connecting to?
>
> mysql -u testuser -p123456 -h localhost
> mysql>CREATE DATABASE cake_testing;
> mysql>exit;
>
> then use 'database' => 'cake_testing',

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

CakeRequest is('mobile'): Solved

I replaced the CakeRequest::is format with $this->request->is and all
worked as prescribed. Ignore last post.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

CakeRequest is('mobile')

I am having trouble getting the CakeRequest::is('mobile') function to
work for iPad and Android devices. I scoured existing documentation/
groups with no luck.

Basically if is a mobile browser I want to view CSS slightly
differently, only slight changes thats why I did not go to separate
view file.

In AppController beforeFilter I have
CakeRequest::addDetector('mobile', array('env' => 'HTTP_USER_AGENT',
'options' => array('iPad')));

I tried several other calls without success:
CakeRequest::addDetector('ipad', array('env' => 'HTTP_USER_AGENT',
'options' => array('iPad')));
CakeRequest::addDetector('ipad_pattern', array('env' =>
'HTTP_USER_AGENT', 'pattern' => '/iPad/i'));
CakeRequest::addDetector('gecko', array('env' => 'HTTP_USER_AGENT',
'pattern' => "/Gecko/i"));

This View code:
echo 'Browser: ' . $_SERVER['HTTP_USER_AGENT']
. ' [mobile:' . CakeRequest::is('mobile') . ']'
. ' [gecko:' . CakeRequest::is('gecko') . ']'
. ' [ipad:' . CakeRequest::is('ipad') . ']'
. ' [ipad pattern:' . CakeRequest::is('ipad_pattern') . ']';

Returns on Firefox, same results for iPad, Android (tho different user
agent stuff):
Browser: Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/
8.0 [mobile:] [gecko:] [ipad:] [ipad pattern:]

Any insights?

Thanks!

GB

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: CakePHP and a normalized database

if you read book.cakephp.org find answers to these questions
and more. see the blog tutorial but start reading from the beginning




On 31 December 2011 18:03, lcano <luis.a.cano@gmail.com> wrote:
Clint,Thanks a lot! Your code worked and now I am able to retrieve
information from different tables within the User model.
Now, my next question would be. How would inserting data work? Does
cakephp take care of that automatically as well?
Thanks,
Luis
On Dec 30, 7:56 pm, Clint <ctf...@student.monash.edu> wrote:
> Hi, the following should help (for v1.3)
>
> It joins the User to the Person and then to the Address.. linking the rest of the tables should be similar.
>
> <?php
>
> class User extends AppModel {
>     var $name = 'User';
>
>     var $hasOne = array(
>         'Person' => array(
>             'className'    => 'Person',
>             'foreignKey'   => 'id',
>             'dependent'    => true,
>             ),
>         'Address' => array(
>             'className' => 'Address',
>             'foreignKey' => false,
>             'type' => 'LEFT',
>             'conditions' => array('Address.id = Person.address_id')
>             )
>         );
>
> }
>
> ?>
>
> If you use the foreignKey option when trying to link in Address, it tries to match the User.id to the Address.id, hence why I've set the condition instead. I was hoping that you could do nested 'hasOne' options, but doesn't seem so..
>
> Clint
>
>
>
>
>
>
>
> > Quick question, I have the following normalized MySQL database with
> > tables:
>
> > Users
> >  - id
> >  - username
> >  - password
> >  - person_id
>
> > People
> >  - id
> >  - firstname
> >  - lastname
> >  - address_id
> >  - email_id
>
> > Addresses
> >  - id
> >  - address
> >  - city_id
> >  - state_id
> >  - country_id
> >  - zipcode_id
>
> > Countries
> >  - id
> >  - country
>
> > I have been having problems setting the correct cakephp Model
> > relations between them. Actually, after reading the documentation I'm
> > not really sure if it's even possible to have this kind of databas
> > structure work with cakephp.
>
> > So far this is what I have:
> > Users - belongsTo/hasOne - People (person_id)
> > People - belongsTo/hasOne - Addresses (address_id)
> > Addresses - belongsTo/hasOne - Countries (country_id)
>
> > So, when I use the User model how can I have cakephp return everything
> > from the user's firstname, lastname, to the address including country
> > and states?
> > To make matters more difficult, how can I have cakePHP (using the
> > FormHelper) insert an user account that has the firstname and lastname
> > (this I already got working), and also the address, city, state and
> > country (this I can't figure it out)?
>
> > My issue is that the Countries table for example is related to the
> > Address table but not to the People table directly nor the Users table
> > directly.
>
> > Any help or guidance would be truly appreciated.
>
> > Thanks in advance.
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: CakePHP and a normalized database

Clint,Thanks a lot! Your code worked and now I am able to retrieve
information from different tables within the User model.
Now, my next question would be. How would inserting data work? Does
cakephp take care of that automatically as well?
Thanks,
Luis
On Dec 30, 7:56 pm, Clint <ctf...@student.monash.edu> wrote:
> Hi, the following should help (for v1.3)
>
> It joins the User to the Person and then to the Address.. linking the rest of the tables should be similar.
>
> <?php
>
> class User extends AppModel {
>     var $name = 'User';
>
>     var $hasOne = array(
>         'Person' => array(
>             'className'    => 'Person',
>             'foreignKey'   => 'id',
>             'dependent'    => true,
>             ),
>         'Address' => array(
>             'className' => 'Address',
>             'foreignKey' => false,
>             'type' => 'LEFT',
>             'conditions' => array('Address.id = Person.address_id')
>             )
>         );
>
> }
>
> ?>
>
> If you use the foreignKey option when trying to link in Address, it tries to match the User.id to the Address.id, hence why I've set the condition instead. I was hoping that you could do nested 'hasOne' options, but doesn't seem so..
>
> Clint
>
>
>
>
>
>
>
> > Quick question, I have the following normalized MySQL database with
> > tables:
>
> > Users
> >  - id
> >  - username
> >  - password
> >  - person_id
>
> > People
> >  - id
> >  - firstname
> >  - lastname
> >  - address_id
> >  - email_id
>
> > Addresses
> >  - id
> >  - address
> >  - city_id
> >  - state_id
> >  - country_id
> >  - zipcode_id
>
> > Countries
> >  - id
> >  - country
>
> > I have been having problems setting the correct cakephp Model
> > relations between them. Actually, after reading the documentation I'm
> > not really sure if it's even possible to have this kind of databas
> > structure work with cakephp.
>
> > So far this is what I have:
> > Users - belongsTo/hasOne - People (person_id)
> > People - belongsTo/hasOne - Addresses (address_id)
> > Addresses - belongsTo/hasOne - Countries (country_id)
>
> > So, when I use the User model how can I have cakephp return everything
> > from the user's firstname, lastname, to the address including country
> > and states?
> > To make matters more difficult, how can I have cakePHP (using the
> > FormHelper) insert an user account that has the firstname and lastname
> > (this I already got working), and also the address, city, state and
> > country (this I can't figure it out)?
>
> > My issue is that the Countries table for example is related to the
> > Address table but not to the People table directly nor the Users table
> > directly.
>
> > Any help or guidance would be truly appreciated.
>
> > Thanks in advance.
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

That is a much better suggestion :)



On Sat, Dec 31, 2011 at 9:49 AM, Sam Sherlock <sam.sherlock@gmail.com> wrote:
because this is blank

 'database' => '',

what is the name of the mysql database your connecting to?

mysql -u testuser -p123456 -h localhost
mysql>CREATE DATABASE cake_testing;
mysql>exit;

then use  'database' => 'cake_testing',

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

I'm sure you have tried it, but have you tried Login "Root" and Password "Root"?
Regards,
Tim

On Sat, Dec 31, 2011 at 2:59 AM, Ronghua <ronghuazhao@gmail.com> wrote:
Hi, today is first day I'm using cake. I have setup CakePHP 2.0.4. In
\app\Config\database.php, the configuration is as below
<?php

class DATABASE_CONFIG {
       public $default = array(
           'datasource' => 'Database/Mysql',
           'persistent' => false,
           'host' => 'localhost',
           'login' => 'testuser',
           'password' => '123456',
           'database' => '',
           'prefix' => '',
           'encoding' => ''
       );
}

I can connect to mysql with MySQLQueryBrowser by testuser and pwd
123456, but I can't connect to database through Cake. Here is the
description in the website. Can someone help me here? From the website
reference, seems nothing else need to change.

Your version of PHP is 5.2.6 or higher.

Your tmp directory is writable.

The FileEngine is being used for caching. To change the config edit
APP/Config/core.php

Your database configuration file is present.

Cake is NOT able to connect to the database.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake is NOT able to connect to the database.

because this is blank

 'database' => '',

what is the name of the mysql database your connecting to?

mysql -u testuser -p123456 -h localhost
mysql>CREATE DATABASE cake_testing;
mysql>exit;

then use  'database' => 'cake_testing',

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake optimization

Use a dedicated memcached server for your caching.


On Dec 31, 2011, at 8:59 AM, Phang Mulianto wrote:

you should also consider to optimize your web server and os layer, javascript caching in your app and also the image caching in user browser...it will make a difference for the effort...

what's your expect in load time results?

On Dec 31, 2011 4:45 AM, "Dee Johnson" <devariojay@gmail.com> wrote:
Hi guys.

I have a optimization question.

I have already used $persistModel = true, optimized by queries with containable and made sure all tables had indices. 

I still would like a speed increase as pages are taking at the min 1.5 sec and at the max 8 seconds (on random occasions).  I tried to use file caching for the pages that dont serve frequently changing or updating data but it didnt seem to give much of a boost.

Any other suggestions to try?  Thanks 



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: how to connect database

This question isn't related to CakePHP framework, please check the PHP (language) documentation at PHP.net

--
Thiago Belem,
Desenvolvedor WEB

Enviado do meu Android

Em 31/12/2011 14:42, "paresh kotar" <paresh.kotar@gmail.com> escreveu:
I am a learner in php..I have basic knowledge of HTML and C Language.
I want to know how to connect database. In PHP using MS SQL.

Paresh Kotar.
Ranghola(dist : Bhavnagar , Ta : Umrala, Country : India)
9510411431

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake optimization

you should also consider to optimize your web server and os layer, javascript caching in your app and also the image caching in user browser...it will make a difference for the effort...

what's your expect in load time results?

On Dec 31, 2011 4:45 AM, "Dee Johnson" <devariojay@gmail.com> wrote:
Hi guys.

I have a optimization question.

I have already used $persistModel = true, optimized by queries with containable and made sure all tables had indices. 

I still would like a speed increase as pages are taking at the min 1.5 sec and at the max 8 seconds (on random occasions).  I tried to use file caching for the pages that dont serve frequently changing or updating data but it didnt seem to give much of a boost.

Any other suggestions to try?  Thanks 


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: get current url as array

I am talking about the complete array to be passed to Html::url() /
Html::link()
of course there are tons of ways to get the data itself
just saw today: Router::parse($this->request->here(false));
besides 10 other ways.

but you would either have to manually join them:
array('controller'=>$this->params['controller'], ...)
or you would have to merge or unset a lot of stuff from it (see above
example with Router::getParams(true);)

out of the box we can only retrieve the final string (in the view
layer with Html::url()) - which is unfortunate in an environment where
every url is usually array-based...

On 31 Dez., 13:04, mike karthauser <mi...@brightstorm.co.uk> wrote:
> You should be able to get the data you need in $this->params.
>
> Mike Karthauser
> Brightstorm limited
> Tel: 07939252144
>
> On 31 Dec 2011, at 12:01, euromark <dereurom...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > any feedback?
> > seems like this is a missing functionality.
>
> > example:
> > admin/authplugin/users/edit/2
>
> > I would expect to find some router method to get
>
> > $url = array(
> >    'admin' => 1
> >    'plugin' => 'authplugin'
> >    'controller' => 'users'
> >    'action' => 'edit'
> >    2
> > )
> > for example
> > maybe with Router::urlAsArray()
> > which would be similar to the result of Router::parse() but it already
> > contains the passed and named params as expected
> > to easily adjust it before passing it to Html::url() or Html::link():
>
> > $url[#] = 'somehash';
> > or
> > $url[] = 'somepassedparam';
> > or
> > $url['key'] = 'somenamedparam';
>
> > echo $this->Html->link('Title', $url);
>
> > On 28 Dez., 21:59, euromark <dereurom...@googlemail.com> wrote:
> >> ...or for any url for that matter (for adding some named/pass params
> >> etc)
>
> >> PS: I forgot
> >>         if (isset($urlParams['prefix'])) {
> >>                 unset($urlParams['prefix']);
> >>         }
>
> >> On 28 Dez., 21:04, euromark <dereurom...@googlemail.com> wrote:
>
> >>> am I missing sth or is there no url() method etc for returning the
> >>> current url as array?
> >>> I only know this way:
>
> >>>                 $urlParams = Router::getParams(true);
> >>>                 $urlParams = am($urlParams, $urlParams['named'],
> >>> $urlParams['pass']);
> >>>                 unset($urlParams['named']);
> >>>                 unset($urlParams['pass']);
>
> >>> but it seems a little bit like overhead...
> >>> does anyone know how to do that easier?
> >>> maybe we should introduce Router::urlAsArray()
> >>> with default NULL => return current ?
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: get current url as array

You should be able to get the data you need in $this->params.

Mike Karthauser
Brightstorm limited
Tel: 07939252144

On 31 Dec 2011, at 12:01, euromark <dereuromark@googlemail.com> wrote:

> any feedback?
> seems like this is a missing functionality.
>
> example:
> admin/authplugin/users/edit/2
>
> I would expect to find some router method to get
>
> $url = array(
> 'admin' => 1
> 'plugin' => 'authplugin'
> 'controller' => 'users'
> 'action' => 'edit'
> 2
> )
> for example
> maybe with Router::urlAsArray()
> which would be similar to the result of Router::parse() but it already
> contains the passed and named params as expected
> to easily adjust it before passing it to Html::url() or Html::link():
>
> $url[#] = 'somehash';
> or
> $url[] = 'somepassedparam';
> or
> $url['key'] = 'somenamedparam';
>
> echo $this->Html->link('Title', $url);
>
>
>
>
> On 28 Dez., 21:59, euromark <dereurom...@googlemail.com> wrote:
>> ...or for any url for that matter (for adding some named/pass params
>> etc)
>>
>> PS: I forgot
>> if (isset($urlParams['prefix'])) {
>> unset($urlParams['prefix']);
>> }
>>
>> On 28 Dez., 21:04, euromark <dereurom...@googlemail.com> wrote:
>>
>>
>>
>>
>>
>>
>>
>>> am I missing sth or is there no url() method etc for returning the
>>> current url as array?
>>> I only know this way:
>>
>>> $urlParams = Router::getParams(true);
>>> $urlParams = am($urlParams, $urlParams['named'],
>>> $urlParams['pass']);
>>> unset($urlParams['named']);
>>> unset($urlParams['pass']);
>>
>>> but it seems a little bit like overhead...
>>> does anyone know how to do that easier?
>>> maybe we should introduce Router::urlAsArray()
>>> with default NULL => return current ?
>
> --
> Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
>

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: get current url as array

any feedback?
seems like this is a missing functionality.

example:
admin/authplugin/users/edit/2

I would expect to find some router method to get

$url = array(
'admin' => 1
'plugin' => 'authplugin'
'controller' => 'users'
'action' => 'edit'
2
)
for example
maybe with Router::urlAsArray()
which would be similar to the result of Router::parse() but it already
contains the passed and named params as expected
to easily adjust it before passing it to Html::url() or Html::link():

$url[#] = 'somehash';
or
$url[] = 'somepassedparam';
or
$url['key'] = 'somenamedparam';

echo $this->Html->link('Title', $url);


On 28 Dez., 21:59, euromark <dereurom...@googlemail.com> wrote:
> ...or for any url for that matter (for adding some named/pass params
> etc)
>
> PS: I forgot
>         if (isset($urlParams['prefix'])) {
>                 unset($urlParams['prefix']);
>         }
>
> On 28 Dez., 21:04, euromark <dereurom...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > am I missing sth or is there no url() method etc for returning the
> > current url as array?
> > I only know this way:
>
> >                 $urlParams = Router::getParams(true);
> >                 $urlParams = am($urlParams, $urlParams['named'],
> > $urlParams['pass']);
> >                 unset($urlParams['named']);
> >                 unset($urlParams['pass']);
>
> > but it seems a little bit like overhead...
> > does anyone know how to do that easier?
> > maybe we should introduce Router::urlAsArray()
> > with default NULL => return current ?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Cake is NOT able to connect to the database.

Hi, today is first day I'm using cake. I have setup CakePHP 2.0.4. In
\app\Config\database.php, the configuration is as below
<?php

class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'testuser',
'password' => '123456',
'database' => '',
'prefix' => '',
'encoding' => ''
);
}

I can connect to mysql with MySQLQueryBrowser by testuser and pwd
123456, but I can't connect to database through Cake. Here is the
description in the website. Can someone help me here? From the website
reference, seems nothing else need to change.

Your version of PHP is 5.2.6 or higher.

Your tmp directory is writable.

The FileEngine is being used for caching. To change the config edit
APP/Config/core.php

Your database configuration file is present.

Cake is NOT able to connect to the database.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: DebugKit Toolbar - core processing (derived)

Turn debug off, check if Cake caches files in app/tmp

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Friday, December 30, 2011

Re: Multiple Businesses in one database

function index() { $this->Event->recursive = 1; $this->set('events', $this->paginate()); } Can you help me add the find() to the code above. I have a user_id field I'd like to filter on. Thank You

View this message in context: Re: Multiple Businesses in one database
Sent from the CakePHP mailing list archive at Nabble.com.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

how to connect database

I am a learner in php..I have basic knowledge of HTML and C Language.
I want to know how to connect database. In PHP using MS SQL.

Paresh Kotar.
Ranghola(dist : Bhavnagar , Ta : Umrala, Country : India)
9510411431

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: CakePHP and a normalized database

Hi, the following should help (for v1.3)

It joins the User to the Person and then to the Address.. linking the rest of the tables should be similar.

<?php

class User extends AppModel {
var $name = 'User';

var $hasOne = array(
'Person' => array(
'className' => 'Person',
'foreignKey' => 'id',
'dependent' => true,
),
'Address' => array(
'className' => 'Address',
'foreignKey' => false,
'type' => 'LEFT',
'conditions' => array('Address.id = Person.address_id')
)
);

}

?>

If you use the foreignKey option when trying to link in Address, it tries to match the User.id to the Address.id, hence why I've set the condition instead. I was hoping that you could do nested 'hasOne' options, but doesn't seem so..

Clint


> Quick question, I have the following normalized MySQL database with
> tables:
>
> Users
> - id
> - username
> - password
> - person_id
>
> People
> - id
> - firstname
> - lastname
> - address_id
> - email_id
>
> Addresses
> - id
> - address
> - city_id
> - state_id
> - country_id
> - zipcode_id
>
> Countries
> - id
> - country
>
> I have been having problems setting the correct cakephp Model
> relations between them. Actually, after reading the documentation I'm
> not really sure if it's even possible to have this kind of databas
> structure work with cakephp.
>
> So far this is what I have:
> Users - belongsTo/hasOne - People (person_id)
> People - belongsTo/hasOne - Addresses (address_id)
> Addresses - belongsTo/hasOne - Countries (country_id)
>
> So, when I use the User model how can I have cakephp return everything
> from the user's firstname, lastname, to the address including country
> and states?
> To make matters more difficult, how can I have cakePHP (using the
> FormHelper) insert an user account that has the firstname and lastname
> (this I already got working), and also the address, city, state and
> country (this I can't figure it out)?
>
> My issue is that the Countries table for example is related to the
> Address table but not to the People table directly nor the Users table
> directly.
>
> Any help or guidance would be truly appreciated.
>
> Thanks in advance.
>
> --
> Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

loadModel() changes FormHelper output in Cake 2.0.4

I suspect this might be a bug--looking for confirmation, and/or advice
on the best place to report it.

I have a controller with no associated model. In other words,
public $uses = null;

I use FormHelper to build a form for a controller action. Because
there is no model, the form's ID and input names are not decorated
with the model name.

I use loadModel() to help process the submitted form values, after
checking $this->request->isPost(). When FormHelper creates the form
after this, it uses the loaded model name in the form's ID and input
names. This means subsequently submitted form values have "moved" to
a different location in $this->request->data.

Maybes the workaround is to call loadModel() on every action, whether
I need to use it or not...but that is awkward.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake optimization

cache your queries using a dedicated memcached server.

Sent from my iPhone

On Dec 30, 2011, at 12:45 PM, Dee Johnson <devariojay@gmail.com> wrote:

Hi guys.

I have a optimization question.

I have already used $persistModel = true, optimized by queries with containable and made sure all tables had indices. 

I still would like a speed increase as pages are taking at the min 1.5 sec and at the max 8 seconds (on random occasions).  I tried to use file caching for the pages that dont serve frequently changing or updating data but it didnt seem to give much of a boost.

Any other suggestions to try?  Thanks 


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Cake optimization

Hi guys.

I have a optimization question.

I have already used $persistModel = true, optimized by queries with containable and made sure all tables had indices. 

I still would like a speed increase as pages are taking at the min 1.5 sec and at the max 8 seconds (on random occasions).  I tried to use file caching for the pages that dont serve frequently changing or updating data but it didnt seem to give much of a boost.

Any other suggestions to try?  Thanks 


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Media view 1.3

I actually already had debug to 2, but on the bright side I figured
out what was wrong, the file on the server had a different name, thats
why I couldnt be found...

On Dec 30, 2:34 pm, Tilen Majerle <tilen.maje...@gmail.com> wrote:
> set debug to 2 and you will see what's going wrong :)
> --
> Lep pozdrav, Tilen Majerlehttp://majerle.eu
>
> 2011/12/30 JTiki <jeremyt...@gmail.com>
>
>
>
>
>
>
>
> > I've recently been trying to get a media view up and running, but for
> > some reason I keep getting this Error "Error: The requested address '/
> > events/download' was not found on this server."
> > My controller code is below
>
> > function download () {
> >        $this->view = 'Media';
> >        $params = array(
> >              'id' => 'SalemFall2011Newsletter.pdf',
> >              'name' => 'SalemFall2011Newsletter',
> >              'download' => true,
> >              'extension' => 'pdf',  // must be lower case
> >              'path' => APP . 'webroot' . DS . 'files' . DS   // don't
> > forget terminal 'DS'
> >       );
> >       $this->set($params);
> >    }
>
> > Any ideas?
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Media view 1.3

set debug to 2 and you will see what's going wrong :)
--
Lep pozdrav, Tilen Majerle



2011/12/30 JTiki <jeremytiki@gmail.com>
I've recently been trying to get a media view up and running, but for
some reason I keep getting this Error "Error: The requested address '/
events/download' was not found on this server."
My controller code is below

function download () {
       $this->view = 'Media';
       $params = array(
             'id' => 'SalemFall2011Newsletter.pdf',
             'name' => 'SalemFall2011Newsletter',
             'download' => true,
             'extension' => 'pdf',  // must be lower case
             'path' => APP . 'webroot' . DS . 'files' . DS   // don't
forget terminal 'DS'
      );
      $this->set($params);
   }

Any ideas?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Media view 1.3

I've recently been trying to get a media view up and running, but for
some reason I keep getting this Error "Error: The requested address '/
events/download' was not found on this server."
My controller code is below

function download () {
$this->view = 'Media';
$params = array(
'id' => 'SalemFall2011Newsletter.pdf',
'name' => 'SalemFall2011Newsletter',
'download' => true,
'extension' => 'pdf', // must be lower case
'path' => APP . 'webroot' . DS . 'files' . DS // don't
forget terminal 'DS'
);
$this->set($params);
}

Any ideas?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: DebugKit Toolbar - core processing (derived)

Try testing the web server, not your site. For example, with apache you have  "ab" that measures the web site performance, serving many times a page. In the apache web site you'll find more info about testing performance.

I hope this helps you.

Regards,


Alejandro.



El jueves 29 de diciembre de 2011, Alex Bovey <alex@bovey.co.uk> escribió:
> Hi all,
> I've just moved a site (at the client's request) from my own VPS where it was performing very well to some cheap shared hosting (123-reg.co.uk) and surprise surprise it's pretty slow.
> Using the DebugKit Toolbar I'm seeing a massive performance hit in core processing (derived) on the timeline - it's taking up to 40 seconds!  Any pointers for where to start looking for the cause of this?
> Thanks all,
> Alex
>
> --
> Alex Bovey
> Web Developer | Alex Bovey Consultancy Ltd
> Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
>
> --
> Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
>  
>  
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
>

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: DebugKit Toolbar - core processing (derived)

Anyone? :)

On Thu, Dec 29, 2011 at 3:41 PM, Alex Bovey <alex@bovey.co.uk> wrote:
Hi all,

I've just moved a site (at the client's request) from my own VPS where it was performing very well to some cheap shared hosting (123-reg.co.uk) and surprise surprise it's pretty slow.

Using the DebugKit Toolbar I'm seeing a massive performance hit in core processing (derived) on the timeline - it's taking up to 40 seconds!  Any pointers for where to start looking for the cause of this?

Thanks all,

Alex

--
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php