Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » can't have a database table called 'class' (for obvious reasons)
can't have a database table called 'class' [message #1943] Mon, 09 February 2009 10:46 Go to next message
ikatz is currently offline  ikatz
Messages: 40
Registered: December 2007
Location: Durham, NH
Member
This problem seems pretty obvious in hindsight, but I created a table called "class", which causes Radicore to generate a class file with the name "class" -- a syntax error.

I would suggest adding some sort of check for table names that won't translate to PHP classes, when they are first imported into the dictionary. Or, rather than making a list of words that are reserved, it might be easier to just run "php -l" on each generated file.

I don't mind correcting my own naming errors (to fix my problem, I'm renaming "class" to "course"); my concern is that the Radicore application generates PHP scripts that don't parse.

Re: can't have a database table called 'class' [message #1945 is a reply to message #1943] Mon, 09 February 2009 11:03 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2350
Registered: April 2006
Location: Surrey, UK
Senior Member
I'm afraid that there is no easy way to check that a table name (or any other name) would cause PHP (or any related extension) to throw a whoopsie, so I will just have to rely on your own judgement when it comes to creating object names.

Now if only someone could create a function called isThisAGoodName() ....


Re: can't have a database table called 'class' [message #1946 is a reply to message #1945] Mon, 09 February 2009 11:42 Go to previous message
ikatz is currently offline  ikatz
Messages: 40
Registered: December 2007
Location: Durham, NH
Member
No problem!
function isThisAGoodName($tablename)
{
        //short version requires PECL extension
        //return runkit_lint ("<?php class $tablename {} ?" .  ">");

        //"long" version
        $temp_file = tempnam(sys_get_temp_dir(), 'rad');
        file_put_contents($temp_file, "<?php class $tablename {} ?>");

        $result = `php -lq $temp_file`;

        unlink($temp_file);
        return 0 === strpos($result, "No syntax errors detected");
}
Previous Topic: Download of file where name contains spaces
Next Topic: Problem when ListView Total causes new page
Goto Forum:
  


Current Time: Mon Jun 17 19:16:13 EDT 2024

Total time taken to generate the page: 0.01071 seconds