echo "<br/>"; echo "The 3 results will be normalised into the tables:<br/>"; echo " 1.) user_address<br/>"; echo " 2.) user_payment<br/>"; echo " 3.) user<br/>"; echo "<br/>"; $redisql->normalize("user", "address,payment"); echo "<br/>"; echo "<br/>"; $redisql->select("user.pk,user.name,user.status,user_address.city,user_address.street,user_address.pk,user_address.zipcode", "user,user_address", "user.pk=user_address.pk AND user.pk BETWEEN 1 AND 5"); echo "<br/>"; echo "<br/>"; echo "If pure lookup speed of a SINGLE column is the dominant use case<br/>"; echo "We can now denorm the Redisql tables into redis hash-tables<br/>"; echo "which are faster for this use-case<br/>"; echo "<br/>"; echo "denorm user \\user:*\\<br/>"; $redisql->denormalize("user", 'user:*'); echo "HGETALL user:1<br/>"; print_r($redisql->hgetall("user:1")); echo "<br/>"; echo "denorm user \\user:*:payment\\<br/>"; $redisql->denormalize("user_payment", 'user:*:payment'); echo "HGETALL user:1:payment<br/>"; print_r($redisql->hgetall("user:1:payment")); echo "<br/>"; echo "denorm user \\user:*:address\\<br/>"; $redisql->denormalize("user_address", 'user:*:address'); echo "HGETALL user:1:address<br/>"; print_r($redisql->hgetall("user:1:address")); echo "<br/>";
To call this repeatedly (and each time dropping the Redisql table, use: "?table=employee_data&drop=1" */ $database_connection['name'] = "test"; // Mysql DatabaseName $redisql = new Predisql_Client($database_connection, $single_server, NULL); $redisql->echo_command = 1; $redisql->echo_response = 1; $redisql->mysql_echo_command = 1; $table = @$_GET['table']; if (!$table) { echo "this script makes the mysql table designated by the URL variable \"table=\" schemaless<br/>"; return; } $drop = @$_GET['drop']; if ($drop) { try { $redisql->dropTable($table); } catch (Exception $e) { } } try { $redisql->importFromMysql($table); } catch (Exception $e) { } $redisql->dump($table); $wildcard = $table . ':*'; $redisql->denormalize($table, $wildcard); echo "HGETALL {$table}:1<br/>"; print_r($redisql->hgetall("{$table}:1")); echo "<br/>";