Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

New variable each_key for @EACH macro to use array key in query, support for array keys for variables used in @IF macros

givanz7635a20b0ecd
diff --git a/system/sqlp/config.php b/system/sqlp/config.php
index b075da9..d3cf34e 100755
--- a/system/sqlp/config.php
+++ b/system/sqlp/config.php
@@ -36,7 +36,7 @@ return
'filterRegex' => '/\s*:?(?<return>[\w_\.]+)?\s*=?\s*@FILTER\s*\(\s*:(?<data>[\w\._]+)\s*\,\s*(?<columns>[\w_]+),?\s*(?<addmissing>true|false)?,?\s*(?<array>true|false)?\s*\)\s*/ms',
- 'varRegex' => '/:(\w+)/ms',
+ 'varRegex' => '/:([\w+\.])/ms',
'importRegex' => '/import\(([\w\-\_\.\/]+?)\);?/',
@@ -114,7 +114,7 @@ PHP
$sql .= '
PHP
],
-
+
'T_SQL_LIMIT' => [
'/\s*@SQL_LIMIT\s*\(\s*(?<start>.+?),\s*(?<limit>.+?)\s*\)\s*/ms',
<<<'PHP'
diff --git a/system/sqlp/lexer.php b/system/sqlp/lexer.php
index 56380c6..89db9e4 100755
--- a/system/sqlp/lexer.php
+++ b/system/sqlp/lexer.php
@@ -201,9 +201,10 @@ class Lexer {
function ($varMatch) use ($match) {
return
preg_replace_callback(
- '/:(\w+)/ms',
+ '/:([\w\.]+)/ms',
function ($matches) {
- return '$params[\'' . $matches[1] . '\']';
+ return '$' . \Vvveb\dotToArrayKey('params.' . $matches[1]);
+ //return '$params[\'' . $matches[1] . '\']';
},
$match[$varMatch[1]]);
},
diff --git a/system/sqlp/mysqli.php b/system/sqlp/mysqli.php
index 0c63f7e..1e9bfac 100755
--- a/system/sqlp/mysqli.php
+++ b/system/sqlp/mysqli.php
@@ -125,4 +125,4 @@ class %name%SQL {
%fetch_all_start%
$result->fetch_all(MYSQLI_ASSOC)
-%fetch_all_end%
\ No newline at end of file
+%fetch_all_end%
diff --git a/system/sqlp/pgsql.php b/system/sqlp/pgsql.php
index 96ba41b..dfd63a8 100755
--- a/system/sqlp/pgsql.php
+++ b/system/sqlp/pgsql.php
@@ -133,4 +133,4 @@ class %name%SQL {
%fetch_all_start%
$this->db->fetchAll($result)
-%fetch_all_end%
+%fetch_all_end%
\ No newline at end of file
diff --git a/system/sqlp/sqlp.php b/system/sqlp/sqlp.php
index fee4513..ba3524b 100755
--- a/system/sqlp/sqlp.php
+++ b/system/sqlp/sqlp.php
@@ -289,7 +289,8 @@ class SqlP {
preg_replace_callback(
$this->config['varRegex'],
function ($matches) {
- return '$params[\'' . $matches[1] . '\']';
+ return '$' . \Vvveb\dotToArrayKey('params.' . $matches[1]);
+ //return '$params[\'' . $matches[1] . '\']';
},
$match[$varMatch[1]]);
},
@@ -319,6 +320,7 @@ class SqlP {
$each = "\n" . TAB . 'if (isset($params' . $resultKey . ') && is_array($params' . $resultKey . '))' .
'foreach ($params' . $resultKey . ' as $key => $rowParent) { ' . "\n" . TAB . '
$params[\'each\'] = $rowParent;
+ $params[\'each_key\'] = $key;
if (is_array($params[\'each\'])) {
$paramTypes[\'each\'] = \'a\';
} else if (is_int($params[\'each\'])) {