lua_dbd.c revision 047246abec3ea0796e392fe10fe36bb7f87305fc
142N/A * Licensed to the Apache Software Foundation (ASF) under one or more 142N/A * contributor license agreements. See the NOTICE file distributed with 142N/A * this work for additional information regarding copyright ownership. 142N/A * The ASF licenses this file to You under the Apache License, Version 2.0 142N/A * (the "License"); you may not use this file except in compliance with 142N/A * the License. You may obtain a copy of the License at 142N/A * Unless required by applicable law or agreed to in writing, software 142N/A * distributed under the License is distributed on an "AS IS" BASIS, 142N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142N/A * See the License for the specific language governing permissions and 142N/A * limitations under the License. 288N/A ============================================================================= 4280N/A db:close(): Closes an open database connection. 4280N/A ============================================================================= ============================================================================= db:__gc(): Garbage collecting function. ============================================================================= ============================================================================= db:active(): Returns true if the connection to the db is still active. ============================================================================= ============================================================================= db:query(statement): Executes the given database query and returns the number of rows affected. If an error is encountered, returns nil as the first parameter and the error message as the second. ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ ============================================================================= db:escape(string): Escapes a string for safe use in the given database type. ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~*/ ============================================================================= resultset(N): Fetches one or more rows from a result set. ============================================================================= /* Fetch all rows at once? */ /* Just fetch a single row */ ============================================================================= db:select(statement): Queries the database for the given statement and returns the rows/columns found as a table. If an error is encountered, returns nil as the first parameter and the error message as the second. ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ ============================================================================= statement:select(var1, var2, var3...): Injects variables into a prepared statement and returns the number of rows matching the query. ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~*/ /* Fetch the prepared statement and the vars passed */ /* Check if we got enough variables passed on to us. * This, of course, only works for prepped statements made through lua. */ "Error in executing prepared statement: Expected %d arguments, got %d.",
for (x = 0; x <
have; x++) {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ "Database connection seems to be closed, please reacquire it.");
============================================================================= statement:query(var1, var2, var3...): Injects variables into a prepared statement and returns the number of rows affected. ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~*/ /* Fetch the prepared statement and the vars passed */ /* Check if we got enough variables passed on to us. * This, of course, only works for prepped statements made through lua. */ "Error in executing prepared statement: Expected %d arguments, got %d.",
for (x = 0; x <
have; x++) {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ "Database connection seems to be closed, please reacquire it.");
============================================================================= db:prepare(statement): Prepares a statement for later query/select. Returns a table with a :query and :select function, same as the db funcs. ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Count number of variables in statement */ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Push the prepared statement table */ ============================================================================= db:prepared(statement): Fetches a prepared statement made through ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Look for the statement */ "Could not find any prepared statement called %s!",
tag);
/* Push the prepared statement table */ /* lua_push_db_handle: Creates a database table object with database functions and a userdata at index 0, which will call lua_dbgc when garbage collected. ============================================================================= dbacquire(dbType, dbString): Opens a new connection to a database of type _dbType_ and with the connection parameters _dbString_. If successful, returns a table with functions for using the database handle. If an error occurs, returns nil as the first parameter and the error message as the second. See the APR_DBD for a list of database types and connection strings ============================================================================= /*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ "mod_dbd doesn't seem to have been loaded.");
"Could not acquire connection from mod_dbd. If your database is running, this may indicate a permission problem.");
"No database connection string was specified.");
"driver for %s not available",
type);
"can't find driver for %s",
type);
"driver for %s is invalid or corrupted",
"mod_lua not compatible with APR in get_driver");