Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pquery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
pquery
Commits
2198131d
Commit
2198131d
authored
Nov 05, 2011
by
Taddes Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added variable alias fucntionality.
parent
e96bbce1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
39 deletions
+70
-39
pquery.php
pquery.php
+64
-23
pquery.sql.php
pquery.sql.php
+6
-16
No files found.
pquery.php
View file @
2198131d
...
@@ -47,6 +47,20 @@ class pQuery {
...
@@ -47,6 +47,20 @@ class pQuery {
*/
*/
static
$accepts
=
array
(
'boolean'
,
'integer'
,
'double'
,
'string'
,
'array'
,
'object'
,
'NULL'
);
static
$accepts
=
array
(
'boolean'
,
'integer'
,
'double'
,
'string'
,
'array'
,
'object'
,
'NULL'
);
/**
* A list of names of plugins that are required to run a plugin.
*
* @var array
*/
static
$require_plugins
=
array
();
/**
* Aliases for the variable setter and getter.
*
* @var string|array
*/
static
$variable_alias
=
array
();
/**
/**
* The current variable.
* The current variable.
*
*
...
@@ -128,6 +142,40 @@ class pQuery {
...
@@ -128,6 +142,40 @@ class pQuery {
return
$obj
;
return
$obj
;
}
}
/**
* Try to load the file containing the utility class for a specific variable type.
*
* @param mixed $type the variable type of the class to load.
*/
static
function
load_plugin
(
$type
)
{
$path
=
PQUERY_ROOT
.
sprintf
(
self
::
PLUGIN_FILENAME_PATTERN
,
$type
);
if
(
!
file_exists
(
$path
)
)
return
false
;
include_once
$path
;
return
true
;
}
/**
* Include the nescessary files for the given plugins.
*/
static
function
require_plugins
(
/* $plugin1 [ , $plugin2, ... ] */
)
{
$plugins
=
func_get_args
();
foreach
(
$plugins
as
$plugin
)
{
$path
=
PQUERY_ROOT
.
sprintf
(
self
::
PLUGIN_FILENAME_PATTERN
,
$plugin
);
if
(
!
file_exists
(
$path
)
)
{
return
self
::
error
(
'Required plugin "%s" could not be located (looked in "%s").'
,
$plugin
,
$path
);
}
include_once
$path
;
}
}
/**
/**
* Parse the type of the given variable, and convert it if needed.
* Parse the type of the given variable, and convert it if needed.
*
*
...
@@ -158,37 +206,27 @@ class pQuery {
...
@@ -158,37 +206,27 @@ class pQuery {
}
}
/**
/**
*
Try to load the file containing the utility class for a specific variable type
.
*
Getter for {@link variable}
.
*
*
* @
param mixed $type the variable type of the class to load.
* @
see variable_alias
*/
*/
static
function
load_plugin
(
$type
)
{
function
__get
(
$name
)
{
$path
=
PQUERY_ROOT
.
sprintf
(
self
::
PLUGIN_FILENAME_PATTERN
,
$type
);
$class_name
=
get_class
(
$this
);
if
(
!
file_exists
(
$path
)
)
return
false
;
include_once
$path
;
return
true
;
if
(
in_array
(
$name
,
(
array
)
$class_name
::
$variable_alias
)
)
return
$this
->
variable
;
}
}
/**
/**
* Include the nescessary files for the given plugins.
* Setter for {@link variable}.
*
* @see variable_alias
*/
*/
static
function
require_plugins
(
/* $plugin1 [ , $plugin2, ... ] */
)
{
function
__set
(
$name
,
$value
)
{
$
plugins
=
func_get_args
(
);
$
class_name
=
get_class
(
$this
);
foreach
(
$plugins
as
$plugin
)
{
if
(
in_array
(
$name
,
(
array
)
$class_name
::
$variable_alias
)
)
$path
=
PQUERY_ROOT
.
sprintf
(
self
::
PLUGIN_FILENAME_PATTERN
,
$plugin
);
$this
->
variable
=
$value
;
if
(
!
file_exists
(
$path
)
)
{
return
self
::
error
(
'Required plugin "%s" could not be located (looked in "%s").'
,
$plugin
,
$path
);
}
include_once
$path
;
}
}
}
}
}
...
@@ -231,6 +269,9 @@ function _p($variable, $plugin=null) {
...
@@ -231,6 +269,9 @@ function _p($variable, $plugin=null) {
return
new
$class_name
(
$variable
);
return
new
$class_name
(
$variable
);
}
}
/**
* Set an alias for the bas class consistent with plugin aliases.
*/
class_alias
(
'pQuery'
,
'__p'
);
class_alias
(
'pQuery'
,
'__p'
);
?>
?>
\ No newline at end of file
pquery.sql.php
View file @
2198131d
...
@@ -21,6 +21,12 @@ class pQuerySql extends pQuery implements pQueryExtension {
...
@@ -21,6 +21,12 @@ class pQuerySql extends pQuery implements pQueryExtension {
*/
*/
static
$link
;
static
$link
;
/**
* @see pQuery::$variable_alias
* @var string|array
*/
static
$variable_alias
=
'query'
;
/**
/**
* The result of the current query.
* The result of the current query.
*
*
...
@@ -158,22 +164,6 @@ class pQuerySql extends pQuery implements pQueryExtension {
...
@@ -158,22 +164,6 @@ class pQuerySql extends pQuery implements pQueryExtension {
return
$func
(
$this
->
result
);
return
$func
(
$this
->
result
);
}
}
/**
* Getter for property 'query'.
*/
function
__get
(
$name
)
{
if
(
$name
==
'query'
)
return
$this
->
variable
;
}
/**
* Setter for property 'query'.
*/
function
__set
(
$name
,
$value
)
{
if
(
$name
==
'query'
)
$this
->
variable
=
$value
;
}
/**
/**
* Assert that the current query has been executed.
* Assert that the current query has been executed.
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment