dokeos-library
[ class tree: dokeos-library ] [ index: dokeos-library ] [ all elements ]

Class: Database

Source Location: /main/inc/lib/database.lib.php

Class Overview




Methods



Class Details

[line 183]


[ Top ]


Class Methods


method affected_rows [line 701]

void affected_rows( [resource $r = null])

Returns the number of affected rows



Parameters:

resource   $r   Optional database resource

[ Top ]

method count_rows [line 566]

int count_rows( string $table)

Count the number of rows in a table



Tags:

return:  The number of rows in the given table.


Parameters:

string   $table   The table of which the rows should be counted

[ Top ]

method error [line 716]

void error( )



[ Top ]

method escape_string [line 591]

string escape_string( string $string)

Escapes a string to insert into the database as text



Tags:

return:  The escaped string
author:  Yannick Warnier <yannick.warnier@dokeos.com>
author:  Patrick Cool <patrick.cool@UGent.be>, Ghent University


Parameters:

string   $string   The string to escape

[ Top ]

method fetch_array [line 606]

array fetch_array( resource $res, [string $option = 'BOTH'])

Gets the array from a SQL result (as returned by api_sql_query) - help achieving database independence



Tags:

return:  Array of results as returned by php
author:  Yannick Warnier <yannick.warnier@dokeos.com>


Parameters:

resource   $res   The result from a call to sql_query (e.g. api_sql_query)
string   $option   Optional: "ASSOC","NUM" or "BOTH", as the constant used in mysql_fetch_array.

[ Top ]

method fetch_object [line 632]

object Object fetch_object( resource $res, [string $class = null], [array $params = null])

Gets the next row of the result of the SQL query (as returned by api_sql_query) in an object form



Tags:

return:  of class StdClass or the required class, containing the query result row
author:  Yannick Warnier <yannick.warnier@dokeos.com>


Parameters:

resource   $res   The result from a call to sql_query (e.g. api_sql_query)
string   $class   Optional class name to instanciate
array   $params   Optional array of parameters

[ Top ]

method fetch_row [line 650]

array fetch_row( resource $res)

Gets the array from a SQL result (as returned by api_sql_query) - help achieving database independence



Tags:

return:  Array of results as returned by php (mysql_fetch_row)
author:  Yannick Warnier <yannick.warnier@dokeos.com>


Parameters:

resource   $res   The result from a call to sql_query (e.g. api_sql_query)

[ Top ]

method fix_database_parameter [line 529]

the fix_database_parameter( $database_name, string $database_name,)



Tags:

return:  glued parameter if it is not empty, or the current course database (glued) if the parameter is empty.


Parameters:

string   $database_name,   can be empty to use current course db
   $database_name  

[ Top ]

method format_glued_course_table_name [line 547]

void format_glued_course_table_name( $database_name_with_glue, $table)

Structures a course database and table name to ready them

for querying. The course database parameter is considered glued: e.g. COURSE001`.`




Parameters:

   $database_name_with_glue  
   $table  

[ Top ]

method format_table_name [line 557]

void format_table_name( $database, $table)

Structures a database and table name to ready them

for querying. The database parameter is considered not glued, just plain e.g. COURSE001




Parameters:

   $database  
   $table  

[ Top ]

method generate_abstract_course_field_names [line 448]

void generate_abstract_course_field_names( $result_array)

This creates an abstraction layer between database field names and field names expected in code.

This helps when changing database names. It's also useful now to get rid of the 'franglais'.




Tags:

author:  Roan Embrechts
todo:  add more array entries to abstract course info from field names
todo:  what's the use of this function. I think this is better removed. There should be consistency in the variable names and the use throughout the scripts for the database name we should consistently use or db_name or database (db_name probably being the better one)


Parameters:

   $result_array  

[ Top ]

method generate_abstract_user_field_names [line 494]

void generate_abstract_user_field_names( $result_array)

This creates an abstraction layer between database field names and field names expected in code.

This helps when changing database names. It's also useful now to get rid of the 'franglais'.




Tags:

author:  Roan Embrechts
author:  Patrick Cool
todo:  add more array entries to abstract user info from field names
todo:  what's the use of this function. I think this is better removed. There should be consistency in the variable names and the use throughout the scripts


Parameters:

   $result_array  

[ Top ]

method get_course_chat_connected_table [line 665]

void get_course_chat_connected_table( [ $database_name = ''])



Parameters:

   $database_name  

[ Top ]

method get_course_info [line 400]

void get_course_info( the $course_code)

Returns an array with all database fields for the specified course.



Tags:

todo:  shouldn't this be in the course.lib.php script?


Parameters:

the   $course_code   real (system) code of the course (ID from inside the main course table)

[ Top ]

method get_course_list [line 385]

a get_course_list( )



Tags:

return:  list (array) of all courses.
todo:  shouldn't this be in the course.lib.php script?


[ Top ]

method get_course_table [line 317]

void get_course_table( $short_table_name, [ $database_name = ''], string $short_table_name,, string $database_name,)

A more generic function than the older get_course_xxx_table functions, this one can return the correct complete name of any course table of which you pass the short name as a parameter.

Please define table names as constants in this library and use them instead of directly using magic words in your tool code.




Parameters:

string   $short_table_name,   the name of the table
string   $database_name,   optional, name of the course database
  • if you don't specify this, you work on the current course.
   $short_table_name  
   $database_name  

[ Top ]

method get_course_table_prefix [line 270]

void get_course_table_prefix( )

Returns the course table prefix for single database.

Not certain exactly when this is used. Do research. It's used in local.inc.php.




[ Top ]

method get_current_course_database [line 227]

void get_current_course_database( )

Returns the name of the main Dokeos database.



[ Top ]

method get_current_course_glued_database [line 235]

void get_current_course_glued_database( )

Returns the glued name of the current course database.



[ Top ]

method get_database_glue [line 247]

void get_database_glue( )

The glue is the string needed between database and table.

The trick is: in multiple databases, this is a period (with backticks) In single database, this can be e.g. an underscore so we just fake there are multiple databases and the code can be written independent of the single / multiple database setting.




[ Top ]

method get_database_name_prefix [line 259]

void get_database_name_prefix( )

Returns the database prefix.

All created COURSE databases are prefixed with this string.

TIP: this can be convenient e.g. if you have multiple Dokeos installations on the same physical server.




[ Top ]

method get_language_isocode [line 364]

void get_language_isocode( $lang_folder)

Returns the isocode corresponding to the language directory given.



Parameters:

   $lang_folder  

[ Top ]

method get_last_insert_id [line 580]

integer get_last_insert_id( )

Gets the ID of the last item inserted into the database



Tags:

return:  The last ID as returned by the DB function
author:  Yannick Warnier <yannick.warnier@dokeos.com>


[ Top ]

method get_main_database [line 195]

void get_main_database( )

Returns the name of the main Dokeos database.



[ Top ]

method get_main_table [line 301]

void get_main_table( $short_table_name, string $short_table_name,)

A more generic function than the other get_main_xxx_table functions, this one can return the correct complete name of any table of the main database of which you pass the short name as a parameter.

Please define table names as constants in this library and use them instead of directly using magic words in your tool code.




Parameters:

string   $short_table_name,   the name of the table
   $short_table_name  

[ Top ]

method get_scorm_database [line 211]

void get_scorm_database( )

Returns the name of the Dokeos SCORM database.



[ Top ]

method get_scorm_table [line 343]

void get_scorm_table( $short_table_name, string $short_table_name,)

This generic function returns the correct and complete name of any scorm table of which you pass the short name as a parameter. Please define table names as constants in this library and use them instead of directly using magic words in your tool code.



Parameters:

string   $short_table_name,   the name of the table
   $short_table_name  

[ Top ]

method get_statistic_database [line 203]

void get_statistic_database( )

Returns the name of the Dokeos statistics database.



[ Top ]

method get_statistic_table [line 330]

void get_statistic_table( $short_table_name, string $short_table_name,)

This generic function returns the correct and complete name of any statistic table of which you pass the short name as a parameter.

Please define table names as constants in this library and use them instead of directly using magic words in your tool code.




Parameters:

string   $short_table_name,   the name of the table
   $short_table_name  

[ Top ]

method get_user_info_from_id [line 418]

$user_info get_user_info_from_id( [$user_id $user_id = ''])

find all the information about a specified user. Without parameter this is the current user.



Tags:

return:  (array): user_id, lastname, firstname, username, email, ...
author:  Roan Embrechts, first version + converted to Database API
author:  Patrick Cool <patrick.cool@UGent.be>, expanded to get info for any user
version:  30 September 2004
todo:  shouldn't this be in the user.lib.php script?


Parameters:

$user_id   $user_id   (integer): the id of the user

[ Top ]

method get_user_personal_database [line 219]

void get_user_personal_database( )

Returns the name of the database where all the personal stuff of the user is stored



[ Top ]

method get_user_personal_table [line 356]

void get_user_personal_table( $short_table_name, string $short_table_name,)

This generic function returns the correct and complete name of any scorm table of which you pass the short name as a parameter. Please define table names as constants in this library and use them instead of directly using magic words in your tool code.



Parameters:

string   $short_table_name,   the name of the table
   $short_table_name  

[ Top ]

method glue_course_database_name [line 516]

void glue_course_database_name( $database_name)

Glues a course database.

glue format from local.inc.php.




Parameters:

   $database_name  

[ Top ]

method insert_id [line 693]

integer insert_id( )

Recovers the last ID of any insert query executed over this SQL connection



Tags:

return:  Unique ID of the latest inserted row


[ Top ]

method num_rows [line 660]

integer num_rows( resource $res)

Gets the number of rows from the last query result - help achieving database independence



Tags:

return:  The number of rows contained in this result
author:  Yannick Warnier <yannick.warnier@dokeos.com>


Parameters:

resource   $res   The result

[ Top ]

method query [line 712]

void query( $sql, [ $file = ''], [ $line = 0])



Parameters:

   $sql  
   $file  
   $line  

[ Top ]

method result [line 678]

void result( resource $resource, integer $row, [string $field = ''])

Acts as the relative *_result() function of most DB drivers and fetches a

specific line and a field




Parameters:

resource   $resource   The database resource to get data from
integer   $row   The row number
string   $field   Optional field name or number

[ Top ]


Documentation generated on Thu, 12 Jun 2008 13:17:56 -0500 by phpDocumentor 1.4.1