Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
811 views
in Q2A Core by

I see that in column params of table qa_eventlog the data is saved separated by tab jumps \t, for instance:

postid=77    parentid=    parent=    title=All my questions...    content=<p>I wanted to know...    format=html    text=I wanted to know...    tags=news,today    categoryid=    extra=    notify=1    email=

Where can I find a tutorial on how to build such setting / getting values?

Any tip appreciated :)

by
Wow, strange way to store data. I would've used JSON, so much simpler and robust.
by
edited by
Problem with older PHP version (below PHP5.2): json_encode() is not available. See http://php.net/manual/en/function.json-encode.php
by
Okay, I found a nice "workaround":
// convert tab jumps to & to be able to use query function
$toURL = str_replace("\t","&",$keysValues);
// parse as URL
parse_str($toURL, $data);
// access keys in array
$postid = $data['postid'];

2 Answers

+1 vote
by
 
Best answer

Okay, I found a nice "workaround":

// convert tab jumps to & to be able to use query function
$toURL = str_replace("\t","&",$keysValues);

// parse as URL
parse_str($toURL, $data);

// access keys in array
$postid = $data['postid'];

 

0 votes
by

See qa-plugins/event-logger/qa-event-logger.php, from line 154, function process_event.

params get saved as string with /t delimiter, example:

                foreach ($params as $key => $value)
                    $paramstring.=(strlen($paramstring) ? "\t" : '').$key.'='.$this->value_to_text($value);
 

See qa-plugins/badges/qa-badge-widget.php, from line 32:

params get read with /t delimiter, example (before comes a mysql request to read params string):

                $params = array();
                
                $paramsa = explode("\t",$badge['params']);
                foreach($paramsa as $param) {
                    $parama = explode('=',$param);
                    $params[$parama[0]]=$parama[1];
                }
                
                $slug = $params['badge_slug'];

...