fabiokbca
Posts: 18
|
Posted: 02/09/2012, 8:53 AM |
|
Hi guys. Firstly sorry for my bad english.
I have a problem in before update/execute update event.
I need add in other table any information of textarea control. But $formname->$textareacontrolname->GetValue() don't work corretly.
My code is:
function f_Salvaanotacao(){
global $emprestimo;
if (trim($emprestimo->txtAnotacao->GetValue()) != ""){
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES (";
$inserir .= CCGetFromGet("id_emprestimo") . ",";
$inserir .= "'". $anotacao . "',";
$inserir .= CCGetUserId() . ")";
mysql_select_db('test');
$inserir = mysql_query($inserir) or die(mysql_error());
}
}
It is a first time i have a problem like this.
Someone can help me?
|
|
|
andy
Posts: 183
|
Posted: 02/09/2012, 10:57 AM |
|
If you use the CCToSQL(variable,ccsText) to encapsulate your variables, CCS will make them SQL friendly.
You can also define your connection as global, then open the connection, execute the defined insert query, then close the connection again.
How about this.:
function f_Salvaanotacao(){
global $DBConnection1; //Or use your connection name!!
global $emprestimo;
if (trim($emprestimo->txtAnotacao->GetValue()) != ""){
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES ("
.CCToSQL(CCGetFromGet("id_emprestimo"),ccsInteger).","
.CCToSQL($anotacao,ccsText).","
.CCToSQL(CCGetUserId(),ccsInteger).")";
$db = new clsDBConnection1();
$db->query($inserir);
$db->close();
}
}
_________________
Andy
RAD tools for rich UI controls:
http://www.koolphptools.com |
|
|
fabiokbca
Posts: 18
|
Posted: 02/10/2012, 3:26 AM |
|
Hello
The $emprestimo->txtAnotacao->GetValue() returns ""
the query works well, only txtanotacao value dont work corretly.
|
|
|
andy
Posts: 183
|
Posted: 02/10/2012, 4:52 AM |
|
What data type is the value?
The available parameters for the CCToSQL(variable, type) are:
ccsDate, ccsBoolean, ccsInteger, ccsFloat, ccsText, ccsMemo
Are you sure that the value appears on the form as GetValue() only grabs the content of the field on the form in the browser...?
I think I can see where the error is (use $emprestimo as variable not $anotacao in sql statement) :
function f_Salvaanotacao(){
global $DBConnection1; //Or use your connection name!!
global $emprestimo;
if (trim($emprestimo->txtAnotacao->GetValue()) != ""){
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES ("
.CCToSQL(CCGetFromGet("id_emprestimo"),ccsInteger).","
.CCToSQL($emprestimo,ccsText).","
.CCToSQL(CCGetUserId(),ccsInteger).")";
$db = new clsDBConnection1();
$db->query($inserir);
$db->close();
}
}
Better still...
May be you should set the variable first then use it. e.g.
function f_Salvaanotacao(){
global $DBConnection1; //Or use your connection name!!
global $emprestimo;
$var_anotacao = $emprestimo->txtAnotacao->GetValue();
if (trim($var_anotacao) != ""){
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES ("
.CCToSQL(CCGetFromGet("id_emprestimo"),ccsInteger).","
.CCToSQL($var_anotacao,ccsText).","
.CCToSQL(CCGetUserId(),ccsInteger).")";
$db = new clsDBConnection1();
$db->query($inserir);
$db->close();
}
}
_________________
Andy
RAD tools for rich UI controls:
http://www.koolphptools.com |
|
|
fabiokbca
Posts: 18
|
Posted: 02/10/2012, 7:10 AM |
|
Well. i will explain detailed my problem
My custom code works well if i remove if condition, but the value of textarea still empty.
Example in my db table when i run this custom code.
id_anotacao(PK) id_emprestimo(FK) descricao(control value) id_usuario(FK)
1 1 null 1
I'm tried like your suggestion but does not work corretly.
The text area control not return any value.
|
|
|
fabiokbca
Posts: 18
|
Posted: 02/10/2012, 7:12 AM |
|
SOrry for my first post. I made a mistake in $anotacao. Correct is $emprestimo->txtAnotacao->GetValue().
|
|
|
fabiokbca
Posts: 18
|
Posted: 02/10/2012, 9:36 AM |
|
I'm solved the problem.
I'm change textarea to textbox and my function work very well.
For test i change textbox to textarea control and work correctly again. Its very strange error but i'm solved with a very simple solution.
|
|
|
andy
Posts: 183
|
Posted: 02/14/2012, 2:00 AM |
|
Glad you found a solution.
_________________
Andy
RAD tools for rich UI controls:
http://www.koolphptools.com |
|
|
clahti2
Posts: 107
|
Posted: 02/19/2012, 3:54 PM |
|
ya, strange. So if I understand you correctly it didn't work when the control was a text area, but did work when you changed to textbox. AND finally continued to work after changing back to textarea? I am guessing there was a corrected typo somewhere in the iterations
|
|
|
|