n00dles / DM_Matrix

The Matrix is an XML file based Database system for GetSimple 3.1
8 stars 7 forks source link

hmm not working #4

Closed tablatronix closed 12 years ago

tablatronix commented 12 years ago

I get this when i try to do a query $r = $sql->query("SELECT * FROM test");

Notice: Undefined index: test in /hsphere/local/home/salverso/tablatronix.com/getsimple_dev/plugins/DM_Matrix/include/sql4array.php on line 88

n00dles commented 12 years ago

try using the following

global $returnArray;
$newsitems=getSchemaTable(your_table,your_query);

or checkout the function getSchemaTable in include\DM_schema_functions

doing a "select * " throws an error so i've disabled it for the moment.

n00dles commented 12 years ago

a working example for my site is

global $returnArray;
$newsitems=getSchemaTable('news',"SELECT id,publishdate,title,content FROM returnArray ORDER BY publishdate DESC LIMIT 2");
tablatronix commented 12 years ago

Its not the select that's the problem, its the undefined index'. Doesn't matter what I query.

n00dles commented 12 years ago

try using getSchemaTable but make sure your query is on returnArray

tablatronix commented 12 years ago

ohhh, kludgy.

Do you expect to get this working properly or do you know what needs to be done to fix it ? It be nice to get it working properly.

n00dles commented 12 years ago

sorry, was a bit late and I wasn't thinking straight... 8)

the correct way to use it is:

$blog=getSchemaTable('blog');  // name the variable the same as your table name. 
$sql=new sql4array();
$blog = $sql->query('select id,title from blog');  // the FROM here is the array above in the getSchemaTable. 

I hope to fix the getSchemaTable function to replace your table instead of the returnArray which as you say is a bit kludgy...

tablatronix commented 12 years ago

I found alot of issues with this old sql4array code. I dont know if you are i the process of re factoring it. But I have already fixed some of it, let me know if you want me to continue on that or not.

For some reason most of the where patterns have double regex delimiters. So wheres do not work . Also you cannot do a where unless the field you are evaluating is also in the select for some reason. Some select_as array issue, being reused for where also. Code doesn't make alot of sense, is old, and isn't commented.

But not that bad. Did you research any other sql librarys ? I wonder if there even is any.

tablatronix commented 12 years ago

ok i see you were refactoring some stuff, thats why its broken.

I fixed all the issues I was having. Cleaned up regex Got wildcard selects working Got it working so the 'where' field doesn't have to be in present in the select. ( still outputs the field though for now, this needs to be rewritten a bit just a quick fix )

n00dles commented 12 years ago

Ha ha, yeah that figures.. I'm not too hot with regex and hadn't a clue what I was doing to be honest. I was just trying to get rid of the depreciated calls. although anything I tried worked ...

Thanks for doing that...

As for other couldn't find any other libs that could do anything like this one...

Work has me busy the last few days but just want to get the delete functions working on the backend and will probably release a beta version for testing.

Anything else you think it needs ?

tablatronix commented 12 years ago

Not much, I noticed the slug dropdown doesn't select the set id when editing a record, it always shows the first one.

I also think it would be nice to get the tables loaded into the classes global, or allow us to pass a global schema array so we can stuff the schema in to a global sub array and not clutter globals with our table names. But its probably easiest to just add the schema to the global local (asset() loop?) and turn off createfromglobals.

It would also be nice to have our own wrapper object for this and not use the sql4array class directly for normal selects. But plugin authors can use the full class features if they choose too, load their own schemas in etc.

Call wrapper -> query() wrapper creates new sql4array, sets attribs, loads schema in,performs query , returns results.

tablatronix commented 12 years ago

actually we would need an init so we could run multiple queries on the schema in a row and not have to reinit or reload the schema.

So maybe use it like this.

wrapper = new DM_sql;

$rs1=wrapper->DM_query(); $rs2=wrapper->DM_query(); $rs3=wrapper->DM_query();

n00dles commented 12 years ago

Thanks for fixing that class up..

Sounds like a great idea, is there much work in it, do you think?

I've most of the backend working now, all the fields should now work correctly.

Just got to add the delete code and do a fair bit of tidy up on the CSS.

tablatronix commented 12 years ago

I'll try to whip up a wrapper clasS . Do you know if caching is working?

n00dles commented 12 years ago

Not sure about the caching at this stage. Its not working and not quiet sure how I'm going to implement it.

The plan was to implement caching as we have in GS and have whole table in a single xml file for quick loading rather than loading each of the files in, but don't cache big fields like text-editors / code-editors etc... and any that we mark as non-cached.

But if we do that we obviously can't run a sql query on those fields as they won't be loaded.

So i'll have to think about it again. Will probably disable for the first release and get it done for a future revision.

What do you think any better way to do it ?

tablatronix commented 12 years ago

Yeah disabled until later feature.

I wasnt really thinking about this Having to dynamically load tables, oops I might have to figure a way to parse the query load the tables into a global then executing the query. I think the class supports all that, just didn't think it through. I'll look at it again tonight , was busy today working on gs core and chris' server hack

tablatronix commented 12 years ago

Hmm I thought I commited that function this morning. I'll check what I did wrong tonight