No announcement yet.

PHP mySQL result into LUA table?

  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP mySQL result into LUA table?

    Hi, until recently I had built an inteface in my AMS 7.0 order management system to my mySQL database using the luaSQL extension. Unfortunately this (the extension) crashes all over the shop when run on Vista. And yes, it really needs to run on Vista as a lot of my customers are on Vista, and more will migrate to it over time...

    So, I've started to side-step the issue by doing the querys and writes using PHP mySQL instead. There are 3 functions that I had been using in my prototype system. They are...

    This simply opens a connection to the database. I can replicate this easy enough with a new LUA function + PHP function on the server, or possibly roll its function into the following two functions, see below...

    This sends data to the database to be changed. Nothing is sent back (apart from maybe error codes if needed). Again I can handle this easily enough using a LUA/PHP combo. No probs....

    This is where it goes off the map for me. I have to send a query to the database (I can handle that) and within PHP this returns a pointer to the actual DB query return. This can be converted to a array in PHP via a certain command. What I want to ideally do though is to take this array and convert it into a LUA table with the same format as that provided by the SQLite QueryToTable command.

    This is the format that the luaSQL functions return a query in. Its this format that my entire system is based on. So really I need to get the PHP array into exactly the same format table as supplied by my existing MySQLQueryToTable() function.

    So, what I'm asking is, does anyone have any experience in this area that can give advice/help out? I'm a relative noob to PHP/LUA/mySQL... I could probably work this out given enough time, or at least create some kind of bodged system.

    But what I am ideally after here is a simple PHP based functio that will do the trick for me i.e. phpArrayToLuaTable(), or maybe some kind of PHP function that formats an echo in a certain manner, and a LUA side function that takes this string and creates the desired table from it.

    Once I have my system up and running, I'll share the code and examples on the AMS examples forum.

    Any help appreciated