I am using cakephp vesion 2.1.0
I hope this may help you,
App::import('Model', 'ConnectionManager');
$con = new ConnectionManager;
$cn = $con->getDataSource('default');
$cn->query( "CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50) default 'Unknown',
City char(50) default 'Mumbai',
Country char(25),
Birth_Date date)"
);
On Tue, Sep 4, 2012 at 8:04 PM, Julien Duhain <[email protected]>wrote:
> Hi veepee,
> I am having the exact same problem. have you ever found a solution?
>
> On Saturday, February 27, 2010 4:46:12 PM UTC+2, veepee wrote:
>>
>> Hi All,
>>
>> I am new to cakePHP and I've tried googling for this topic but to no
>> avail. I need to create a database table from controller. May i know
>> is it possible to insert into the newly created table, i.e. in this
>> example, the customer table using model?
>>
>> $this->Q->query("CREATE TABLE customer
>> (First_Name char(50),
>> Last_Name char(50),
>> Address char(50) default 'Unknown',
>> City char(50) default 'Mumbai',
>> Country char(25),
>> Birth_Date date)");
>> }
>> $this->loadModel('Customer');
>> $this->Customers->saveAll(**data);
>>
>> I've tried it but this does not work. May I know if there are any
>> alternatives besides creating another insert statement using
>>
>> $this->Q->query("INSERT INTO customer...");
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.