I'm actually working with the latest stable version of Xataface and I had a problem while developing a function to check some SQL request.
In fact in my page containing the users and their profile, I have a field called 'sql_vco_affaires' and in this field I put some custom and sometimes fancy request hard to make automatically elseway. So when I create the client profile, I just put the request SQL in that field and later the client will be able to just execute them. (only SELECT something requests)
So I tried to verify the request, just to see if they throw me an error so here is my function :
- Code: Select all
function beforeSave(&$record)
{
$app =& Dataface_Application::getInstance();
$query =$record->strval('sql_vco_affaires');
$res = mysql_query($query, $app->db());
$sql_error = mysql_error();
if (!$res)
{
return PEAR::raiseError($sql_error . ", il y a une erreur dans votre requête SQL.", DATAFACE_E_NOTICE);
}
}
(don't tell me, I know I need to complete the conditions in the "if", that's just the beginning)
It works fine, it checks the SQL request but then when the error is raised on the page, it's just impossible to change the request. It seems to be save or fixed, I write another request in the 'sql_vco_affaires' field but when I try to save them again or even when I click "next" to modify some other fields of the user, the new value isn't even took in consideration. It just checks and show me the first value it checked. :/
Let's say I want to check "SELECT * FROM LOL;" it will raise me an error because the LOL table doesn't exist. So I erase "SELECT * FROM LOL;" and replace it by "SELECT * FROM users;" for example. But when I click "save" (or when I click "next" and then come back to the page) it throws me back the previous error and the value displayed in the field and also checked it the previous one too !
I don't understand why, so I'm here to ask for help.
Thanks in advance ! (and excuse me if my english isn't perfect : I'm French)