Database Forge add_column query problem |
[eluser]GreenDude[/eluser]
Hi. I'm building an application that processes a xml file and creates a table accordingly. The problem is that some columns have names that include spaces or dots, and the add_column function splits the name inside the query. For example, if I try adding a field called "What the hell", I get the following error: Code: Error Number: 1064 Here's how my array looks like: Code: Array And here's the chunk of php that does the work: Code: $fields = array(); Any idea how I could make the query use the whole name? GreenDude
[eluser]GSV Sleeper Service[/eluser]
you could try putting the table name in quotes, or replacing the spaces with underscores before passing it to add_column. I was bored so I traced the code back to a function called _protect_identifiers in [database]_driver.php, it looks like this is where the backticks are being added, this comment caught my eye. Code: // This function may get "item1 item2" as a string, and so
[eluser]GreenDude[/eluser]
In the end I used a classic db->query to get around it, and it seems to work. Thanks for the tip with the comment, maybe they'll condition the backticks in the future. Or maybe not. Now I find myself with another problem... is there a predefined helper for processing the names I use in the columns and returning a "nicename" for use inside input element names? The underscore is a solution, but if there's something already implemented please give me a hint. Cheers, GreenDude
[eluser]GSV Sleeper Service[/eluser]
url_title will do the job - http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]GreenDude[/eluser]
Thanks again. It works perfectly. Cheers, GreenDude |
Welcome Guest, Not a member yet? Register Sign In |