Conexão com MySql no Yii
#1
Posted 26 March 2009 - 03:16 PM
#2
Posted 26 March 2009 - 04:23 PM
Va em /protected/config/main.php e insira uma entrada em components com o seguinte:
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=nome_da_base',
'username'=>'joao',
'password'=>'minha_senha',
),
[]s!
Cass
#4
Posted 26 March 2009 - 07:10 PM
Criou a base de dados ? O utilizador definido em 'username' tem permissões sobre essa db? A password está correcta? Tem mysql instalado?

Os erros são apenas ao criar o CRUD ? Quanto mais e melhor informação, maior a chance de alguém poder ajudar.
#5
Posted 27 March 2009 - 01:29 PM
#6
Posted 30 March 2009 - 11:54 AM
http://www.yiiframew...nsion/modulegen
cria uma completa aplicação modular de exemplo a partir de uma tabela do seu banco mysql
#7
Posted 30 March 2009 - 01:36 PM

#8
Posted 30 March 2009 - 01:38 PM
#9
Posted 30 March 2009 - 01:43 PM
#10
Posted 30 March 2009 - 01:49 PM
aqui tem alguns exemplos:
criando:
$post=new Post;
$post->createTime=new CDbExpression('NOW()');
// $post->createTime='NOW()'; will not work because
// 'NOW()' will be treated as a string
$post->save();
lendo:
$post=Post::model()->find($condition,$params);
// find the row with the specified primary key
$post=Post::model()->findByPk($postID,$condition,$params);
// find the row with the specified attribute values
$post=Post::model()->findByAttributes($attributes,$condition,$params);
// find the first row using the specified SQL statement
$post=Post::model()->findBySql($sql,$params);
inserindo:
$post=Post::model()->findByPk(10);
$post->title='new post title';
$post->save(); // save the change to database
removendo
$post=Post::model()->findByPk(10); // assuming there is a post whose ID is 10
$post->delete(); // delete the row from the database table
mais info:
http://www.yiiframew...ide/database.ar
#11
Posted 30 March 2009 - 02:13 PM
#12
Posted 30 March 2009 - 10:36 PM
http://www.yiiframew...Command#execute
Tenta ai!

Valeu
#13
Posted 30 March 2009 - 10:39 PM
Mas Max, achei sua extensão interessante.
A issue referente ao yiic que foi fixada, não implementa todas as funcionalidades da sua extensão?
valeu,
Luiz
#15
Posted 31 March 2009 - 03:53 PM
tenho outra dúvida,
como faço para usar o crud com uma tabela que tem múltiplas primary key?