Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
597c1ef5
Commit
597c1ef5
authored
28 years ago
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
Added support for compiled queries.
Rev: lib/modules/Sql.pmod/sql.pike:1.5
parent
4334784f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Sql.pmod/sql.pike
+26
-9
26 additions, 9 deletions
lib/modules/Sql.pmod/sql.pike
with
26 additions
and
9 deletions
lib/modules/Sql.pmod/sql.pike
+
26
−
9
View file @
597c1ef5
/*
/*
* $Id: sql.pike,v 1.
4
1997/0
3/30 19:07:40
grubba Exp $
* $Id: sql.pike,v 1.
5
1997/0
4/23 00:29:03
grubba Exp $
*
*
* Implements the generic parts of the SQL-interface
* Implements the generic parts of the SQL-interface
*
*
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
//.
//.
//. File: sql.pike
//. File: sql.pike
//. RCSID: $Id: sql.pike,v 1.
4
1997/0
3/30 19:07:40
grubba Exp $
//. RCSID: $Id: sql.pike,v 1.
5
1997/0
4/23 00:29:03
grubba Exp $
//. Author: Henrik Grubbström (grubba@infovav.se)
//. Author: Henrik Grubbström (grubba@infovav.se)
//.
//.
//. Synopsis: Implements the generic parts of the SQL-interface.
//. Synopsis: Implements the generic parts of the SQL-interface.
...
@@ -55,11 +55,11 @@ void create(void|string|object host, void|string db,
...
@@ -55,11 +55,11 @@ void create(void|string|object host, void|string db,
} else {
} else {
foreach(get_dir(Sql->dirname), string program_name) {
foreach(get_dir(Sql->dirname), string program_name) {
if ((sizeof(program_name / "_result") == 1) &&
if ((sizeof(program_name / "_result") == 1) &&
(program_name
!= "sql
.pike") &&
(sizeof
(program_name
/ "
.pike")
> 1)
&&
(program_name != "
CVS
")) {
(program_name != "
sql.pike
")) {
/* Don't call ourselves... */
/* Don't call ourselves... */
array(mixed) err;
array(mixed) err;
werror("Trying "+program_name+"...\n");
err = catch {
err = catch {
program p = Sql[program_name];
program p = Sql[program_name];
...
@@ -76,6 +76,7 @@ void create(void|string|object host, void|string db,
...
@@ -76,6 +76,7 @@ void create(void|string|object host, void|string db,
}
}
return;
return;
};
};
werror(describe_backtrace(err)+"\n");
}
}
}
}
}
}
...
@@ -119,13 +120,28 @@ void select_db(string db)
...
@@ -119,13 +120,28 @@ void select_db(string db)
master_sql->select_db(db);
master_sql->select_db(db);
}
}
//. - compile_query
//. Compiles the query (if possible). Otherwise returns it as is.
//. The resulting object can be used multiple times in query() and
//. big_query().
//. > q
//. SQL-query to compile.
string|object compile_query(string q)
{
if (functionp(master_sql->compile_query)) {
return(master_sql->compile_query(q));
}
return(q);
}
//. - query
//. - query
//. Send an SQL query to the underlying SQL-server. The result is returned
//. Send an SQL query to the underlying SQL-server. The result is returned
//. as an array of mappings indexed on the name of the columns.
//. as an array of mappings indexed on the name of the columns.
//. Returns 0 if the query didn't return any result (e.g. INSERT or similar).
//. Returns 0 if the query didn't return any result (e.g. INSERT or similar).
//. > q
//. > q
//. Query to send to the SQL-server.
//. Query to send to the SQL-server. This can either be a string with the
array(mapping(string:mixed)) query(string q)
//. query, or a previously compiled query (see compile_query()).
array(mapping(string:mixed)) query(object|string q)
{
{
object res_obj;
object res_obj;
...
@@ -141,8 +157,9 @@ array(mapping(string:mixed)) query(string q)
...
@@ -141,8 +157,9 @@ array(mapping(string:mixed)) query(string q)
//. the available memory, and returning some more info on the result.
//. the available memory, and returning some more info on the result.
//. Returns 0 if the query didn't return any result (e.g. INSERT or similar).
//. Returns 0 if the query didn't return any result (e.g. INSERT or similar).
//. > q
//. > q
//. Query to send to the SQL-server.
//. Query to send to the SQL-server. This can either be a string with the
object big_query(string q)
//. query, or a previously compiled query (see compile_query()).
object big_query(object|string q)
{
{
if (functionp(master_sql->big_query)) {
if (functionp(master_sql->big_query)) {
return(Sql.sql_result(master_sql->big_query(q)));
return(Sql.sql_result(master_sql->big_query(q)));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment