Hi,
at first i have to say that my english isn't very good but i hope you'll understand me...
here my problem:
i have been programming on a little cms and now i need a function wich alloweds me to read out the content from the database...
... i thought it would be wise to copy the mysql's syntax (just the basic functions) so that somebody who wants to work with this cms can learn it much faster if he knows the mysql syntax.
but now i got problems with the where statment. my idea is that i mark each field and explode it after
here the idea:
select * from table where field1="1" and (field2="2" or field2="3")
the function copys everything after the where into the var $where_statment. and then the string should be marked so that it looks like this:
befor:
field1="1" and (field2="2" or field2="3")
after:
<~CMS~<field1="1">~CMS~> <~CMS~<and>~CMS~> <~CMS~<(>~CMS~><~CMS~<field2="2">~CMS~> <~CMS~<or>~CMS~> <~CMS~<field2="3">~CMS~><~CMS~<😉>~CMS~>
and after exploded ... each field in one var.
i tried it that way:
$where_reg ="(";
$where_reg.="([aA][nN][dD]|[oO][rR])";
$where_reg.="|";
$where_reg.="([(]|[)])";
$where_reg.="|";
$where_reg.="([_[:alnum:]]+)";
$where_reg.="([ ]([=]|[!=]|[<]|[>]|[>]=|[<]=)[ ])";
$where_reg.="(";
$where_reg.="([[:alnum:]])";
$where_reg.="|";
$where_reg.="(\"\'+[\"\'])";
$where_reg.=")";
$where_reg.=")";
$marked_where=eregi_replace("$where_reg","<~CMS~<\0>~CMS~>",$where_statment);
$marked_where=eregi_replace('<~CMS~<>~CMS~>','',$marked_where);
$marked_where=eregi_replace('>~CMS~>([ ]+)<~CMS~<','>~CMS~><~CMS~<',$marked_where);
$splited_where=explode(">~CMS~><~CMS~<",$marked_where);
$max=count($splited_where);
$z1=explode("<~CMS~<",$splited_where[0]);
$z2=explode(">~CMS~>",$splited_where[$max-1]);
if($max==1) {
$z3=explode(">~CMS~>",$z1[1]);
$splited_where[0]=$z3[0];
}
else {
$splited_where[0]=$z1[1];
$splited_where[$max-1]=$z2[0];
}
i hope you'll can help me with this.
and pleace write an email for anser to the following address: santos@inode.at
thank you very much,
Santos