This class allow you to connect to the postgresql database, execute sql, retrieve data. More...
Public Member Functions | |
| __construct ($p_database_id=0, $p_type='dos') | |
| constructor | |
| __toString () | |
| alter_seq ($p_name, $min) | |
| alter the sequence value | |
| apply_patch ($p_name, $from_setup=1) | |
| loop to apply all the path to a folder or a template | |
| close () | |
| wrapper for the function pg_close | |
| commit () | |
| Commit the transaction. | |
| count () | |
| return the number of rows found by the last query, synomym for size() | |
| count_sql ($p_sql, $p_array=null) | |
| Count the number of row returned by a sql statement. | |
| create_sequence ($p_name, $min=1) | |
| exec_sql ($p_string, $p_array=null) | |
| send a sql string to the database | |
| execute ($p_string, $p_array) | |
| wrapper for the function pg_execute | |
| execute_script ($script) | |
| Execute a sql script. | |
| exist_blob ($p_oid) | |
| check if the large object exists | |
| exist_column ($col, $table, $schema) | |
| Check if a column exists in a table. | |
| exist_database ($p_name) | |
| Count the database name in a system view. | |
| exist_schema ($p_name) | |
| exist_sequence ($p_name) | |
| test if a sequence exist | |
| exist_table ($p_name, $p_schema='public') | |
| test if a table exist | |
| exist_view ($p_name) | |
| fetch ($p_indice) | |
| fetch the $p_indice array from the last query | |
| format_name ($p_id, $p_type) | |
| return the name of the database with the domain name | |
| get_array ($p_sql, $p_array=null) | |
| purpose return the result of a sql statment in a array | |
| get_current_seq ($p_seq) | |
| get the current sequence value | |
| get_next_seq ($p_seq) | |
| get the next sequence value | |
| get_value ($p_sql, $p_array=null) | |
| return the value of the sql, the sql will return only one value with the value | |
| get_version () | |
| Get version of a database, the content of the table version. | |
| lo_export ($p_oid, $tmp) | |
| wrapper for the function pg_lo_export | |
| lo_import ($p_oid) | |
| wrapper for the function pg_lo_export | |
| lo_unlink ($p_oid) | |
| wrapper for the function pg_lo_unlink | |
| make_array ($p_sql, $p_null=0) | |
| make a array with the sql | |
| make_list ($sql, $p_array=null) | |
| create a string containing the value separated by comma for use in a SQL in statement | |
| prepare ($p_string, $p_sql) | |
| wrapper for the function pg_prepare | |
| query_to_csv ($ret, $aheader) | |
| with the handle of a successull query, echo each row into CSV and send it directly | |
| rollback () | |
| rollback the current transaction | |
| save_upload_document ($seq) | |
| Save a "piece justificative". | |
| set_encoding ($p_charset) | |
| size () | |
| return the number of rows found by the last query, synomym for count() | |
| start () | |
| @ brief : start a transaction | |
| status () | |
| verify () | |
Static Public Member Functions | |
| static | escape_string ($p_string) |
| wrapper for the function pg_escape_string | |
| static | fetch_all ($ret) |
| wrapper for the function pg_fetch_all | |
| static | fetch_array ($ret, $p_indice=0) |
| wrapper for the function pg_fetch_array | |
| static | fetch_result ($ret, $p_row=0, $p_col=0) |
| wrapper for the function pg_fetch_all | |
| static | fetch_row ($ret, $p_row) |
| wrapper for the function pg_fetch_row | |
| static | num_row ($ret) |
| wrapper for the function pg_NumRows | |
| static | test_me () |
Private Attributes | |
| $db | |
| $ret | |
This class allow you to connect to the postgresql database, execute sql, retrieve data.
Definition at line 33 of file class_database.php.
| Database::__construct | ( | $p_database_id = 0, |
|
$p_type = 'dos' |
|||
| ) |
constructor
| $p_database_id | is the id of the dossier, or the modele following the p_type if = 0 then connect to the repository |
| $p_type | is 'DOS' (defaut) for dossier or 'MOD' |
Definition at line 43 of file class_database.php.
References $a, db, DEBUG, domaine, exist_schema(), exit, phpcompta_password, phpcompta_psql_port, and phpcompta_user.
| Database::__toString | ( | ) |
| \return |
Definition at line 886 of file class_database.php.
| Database::alter_seq | ( | $p_name, | |
| $min | |||
| ) |
alter the sequence value
| $p_name | name of the sequence |
| $min | the start value of the sequence |
Definition at line 230 of file class_database.php.
References $Res, and exec_sql().
Referenced by apply_patch().
| Database::apply_patch | ( | $p_name, | |
$from_setup = 1 |
|||
| ) |
loop to apply all the path to a folder or a template
| $p_name | database name |
| $from_setup | == 1 if called from setup.php |
Definition at line 359 of file class_database.php.
References $i, $max, $Max, $res, $Res, $row, $seq, $sql, $succeed, $to, alter_seq(), DBVERSION, DEBUG, exec_sql(), execute_script(), exist_schema(), get_value(), get_version(), and size().
| Database::close | ( | ) |
| Database::commit | ( | ) |
Commit the transaction.
Definition at line 214 of file class_database.php.
References $Res, and exec_sql().
| Database::count | ( | ) |
return the number of rows found by the last query, synomym for size()
Definition at line 348 of file class_database.php.
Referenced by make_list(), and query_to_csv().
| Database::count_sql | ( | $p_sql, | |
$p_array = null |
|||
| ) |
Count the number of row returned by a sql statement.
| $p_sql | sql string |
| $p_array | if not null we use the safer pg_query_params |
Definition at line 178 of file class_database.php.
References $p_array, and exec_sql().
Referenced by exist_schema(), exist_sequence(), exist_table(), and exist_view().
| Database::create_sequence | ( | $p_name, | |
$min = 1 |
|||
| ) |
Definition at line 510 of file class_database.php.
References $sql, and exec_sql().
|
static |
wrapper for the function pg_escape_string
| $p_string | is the string to escape |
Definition at line 870 of file class_database.php.
Referenced by Anc_Plan\exist(), Anc_Group\insert(), Acc_Ledger\list_operation(), Anc_Acc_List\load_anc_account(), Anc_Acc_List\load_anc_card(), Anc_Acc_List\load_card(), Anc_Table\load_poste(), Anc_Acc_List\load_poste(), Follow_Up\myList(), and Pre_operation\save().
| Database::exec_sql | ( | $p_string, | |
$p_array = null |
|||
| ) |
send a sql string to the database
| $p_string | sql string |
| $p_array | array for the SQL string (see pg_query_params) |
Definition at line 121 of file class_database.php.
References $a, $p_array, $ret, db, and DEBUG.
Referenced by alter_seq(), apply_patch(), Extension\clean(), commit(), count_sql(), create_sequence(), execute_script(), get_array(), get_next_seq(), get_value(), make_array(), rollback(), save_upload_document(), and start().
| Database::execute | ( | $p_string, | |
| $p_array | |||
| ) |
wrapper for the function pg_execute
| $p_string | string name of the stmt given in pg_prepare function |
| $p_array | contains the variables |
Definition at line 841 of file class_database.php.
| Database::execute_script | ( | $script | ) |
Execute a sql script.
| $script | script name |
Definition at line 239 of file class_database.php.
References $script, $sql, DEBUG, exec_sql(), exit, print, and rollback().
Referenced by apply_patch().
| Database::exist_blob | ( | $p_oid | ) |
check if the large object exists
| $p_oid | of the large object |
Definition at line 590 of file class_database.php.
References $r, and get_value().
| Database::exist_column | ( | $col, | |
| $table, | |||
| $schema | |||
| ) |
Check if a column exists in a table.
| $col | : column name |
| $table | :table name |
| $schema | :schema name, default public |
Definition at line 545 of file class_database.php.
References $r, $table, and get_value().
| Database::exist_database | ( | $p_name | ) |
Count the database name in a system view.
| $p_name | string database name |
Definition at line 579 of file class_database.php.
References get_value().
| Database::exist_schema | ( | $p_name | ) |
Definition at line 612 of file class_database.php.
References $r, and count_sql().
Referenced by __construct(), apply_patch(), and Extension\clean().
| Database::exist_sequence | ( | $p_name | ) |
test if a sequence exist
Definition at line 519 of file class_database.php.
References $r, and count_sql().
| Database::exist_table | ( | $p_name, | |
$p_schema = 'public' |
|||
| ) |
test if a table exist
| $p_name | table name |
| $schema | name of the schema default public |
Definition at line 531 of file class_database.php.
References $r, and count_sql().
| Database::exist_view | ( | $p_name | ) |
Definition at line 601 of file class_database.php.
References $r, and count_sql().
| Database::fetch | ( | $p_indice | ) |
fetch the $p_indice array from the last query
| $p_indice | index |
Definition at line 335 of file class_database.php.
|
static |
wrapper for the function pg_fetch_all
| $ret | is the result of pg_exec (exec_sql) |
Definition at line 792 of file class_database.php.
References $ret.
Referenced by Fiche\belong_ledger(), Follow_Up\get(), Anc_Operation\get_balance(), Anc_Operation\get_by_jid(), Acc_Ledger\get_class_def(), Acc_Ledger\get_detail(), Acc_Ledger\get_fiche_def(), Anc_Operation\get_jrid(), Acc_Operation\get_jrnx_detail(), User\get_ledger(), gestion_sold\get_list(), gestion_purchase\get_list(), Anc_Plan\get_list(), Anc_Operation\get_list(), Anc_Account\get_list(), Acc_Report\get_list(), Pre_operation\get_list_ledger(), Anc_Plan\get_poste_analytique(), Fiche\get_quick_code(), Acc_Ledger\get_row(), Acc_Ledger\get_rowSimple(), Acc_Ledger\get_solde(), Acc_Ledger\GetDefLine(), Fiche\getName(), Anc_Balance_Simple\load(), Anc_Group\load(), gestion_purchase\load(), Pre_operation\load(), Pre_op_ods\load(), Pre_op_fin\load(), Pre_op_ven\load(), Pre_Op_Advanced\load(), Pre_op_ach\load(), Acc_Account\load(), Acc_Account_Ledger\load(), Acc_Report\load(), Anc_Balance_Double\load(), Acc_Parm_Code\load_all(), Acc_Ledger_Info\load_all(), Todo_List\load_all(), Fiche_Def_Ref\LoadAll(), Document_modele\myList(), Anc_Group\myList(), Follow_Up\myList(), Follow_Up\short_list(), Fiche\strAttribut(), and Customer\VatListing().
|
static |
wrapper for the function pg_fetch_array
| $ret | is the result of a pg_exec |
| $p_indice | is the index |
Definition at line 783 of file class_database.php.
References $ret.
Referenced by Fiche\blank(), User\Check(), Document_modele\Delete(), Fiche\Display(), Periode\display_form_periode(), Fiche_Def\DisplayAttribut(), Anc_Account\fetch_from_db(), Document\Generate(), Document_type\get(), Anc_Plan\get(), Fiche_Def\Get(), Fiche_Def_Ref\Get(), Acc_Reconciliation\get(), Document\get(), Fiche_Def\get_attr_min(), User\get_available_folder(), Fiche\get_bk_balance(), Supplier\get_by_account(), Customer\get_by_account(), Fiche_Def\get_by_category(), Acc_Operation\get_data(), Periode\get_date_limit(), User\get_exercice(), Acc_Operation\get_internal(), Acc_Account\get_lib(), Acc_Report\get_name(), Acc_Account_Ledger\get_name(), Acc_Ledger\get_name(), Profile_sql\get_object(), Profile_Menu_sql\get_object(), Menu_Ref_sql\get_object(), Jrn_Def_sql\get_object(), User\get_preference(), Acc_Ledger\get_propertie(), Acc_Report\get_row(), Fiche\get_row_result(), Acc_Account_Ledger\get_row_sql(), Acc_Ledger\get_rowSimple(), Acc_Account_Ledger\get_solde(), Acc_Account_Ledger\get_solde_detail(), Fiche\get_solde_detail(), Acc_Ledger\get_type(), Fiche_Def\GetAll(), Fiche_Def\getAttribut(), Fiche\getAttribut(), Fiche\GetByDef(), html_min_page_start(), html_page_start(), isValid_deprecrated(), Acc_Ledger\list_operation(), Acc_Ledger\list_operation_to_reconcile(), Acc_Ledger\listing(), User\load(), Acc_Ledger_Info\load(), Forecast\load(), Forecast_Item\load(), Forecast_Cat\load(), Acc_Tva\load(), Acc_Payment\load(), Acc_Parm_Code\load(), Todo_List\load(), Dossier\load(), Acc_Bilan\load(), User\load_global_pref(), Fiche_Def\myList(), Own\Own(), query_to_csv(), Document_modele\Save(), Document\Send(), ShowMenuFiche(), Profile_Menu\sub_menu(), Document_modele\update(), Fiche\update(), Anc_Operation\update_from_jrnx(), Customer\VatListing(), and Acc_Bilan\warning().
|
static |
wrapper for the function pg_fetch_all
| $ret | is the result of pg_exec (exec_sql) |
| $p_row | is the indice of the row |
| $p_col | is the indice of the col |
Definition at line 803 of file class_database.php.
References $ret.
Referenced by User\Admin(), Periode\display_form_periode(), Fiche\empty_attribute(), Periode\find_periode(), Periode\get_exercice(), Acc_Ledger_Info\insert(), Forecast\insert(), Forecast_Cat\insert(), Forecast_Item\insert(), Acc_Tva\insert(), Todo_List\insert(), Acc_Report\insert(), Periode\is_centralized(), Periode\is_closed(), Periode\is_open(), Acc_Report\load(), gestion_purchase\search_by_jid(), Acc_Ledger_Info\search_id_internal(), Acc_Operation\seek_internal(), and User\set_default_periode().
|
static |
wrapper for the function pg_fetch_row
| $ret | is the result of pg_exec (exec_sql) |
| $p_row | is the indice of the row |
Definition at line 812 of file class_database.php.
References $ret.
Referenced by Html_Table\sql2table().
| Database::format_name | ( | $p_id, | |
| $p_type | |||
| ) |
return the name of the database with the domain name
| $p_id | of the folder WITHOUT the domain name |
| $p_type | dos for folder mod for template |
Definition at line 558 of file class_database.php.
References domaine, echo_error(), and exit.
| Database::get_array | ( | $p_sql, | |
$p_array = null |
|||
| ) |
purpose return the result of a sql statment in a array
| $p_sql | sql query |
| $p_array | if not null we use ExecSqlParam |
Definition at line 501 of file class_database.php.
References $array, $Max, $p_array, $r, and exec_sql().
Referenced by make_list().
| Database::get_current_seq | ( | $p_seq | ) |
get the current sequence value
Definition at line 185 of file class_database.php.
References $Res, and get_value().
| Database::get_next_seq | ( | $p_seq | ) |
get the next sequence value
Definition at line 194 of file class_database.php.
References $Res, $seq, and exec_sql().
| Database::get_value | ( | $p_sql, | |
$p_array = null |
|||
| ) |
return the value of the sql, the sql will return only one value with the value
| $p_sql | the sql stmt example :select s_value from document_state where s_id=2 |
| $p_array | if array is not null we use the ExecSqlParm (safer) |
Definition at line 481 of file class_database.php.
References $array, $p_array, $r, and exec_sql().
Referenced by apply_patch(), exist_blob(), exist_column(), exist_database(), get_current_seq(), and get_version().
| Database::get_version | ( | ) |
Get version of a database, the content of the table version.
Definition at line 324 of file class_database.php.
References $Res, and get_value().
Referenced by apply_patch().
| Database::lo_export | ( | $p_oid, | |
| $tmp | |||
| ) |
| Database::lo_import | ( | $p_oid | ) |
wrapper for the function pg_lo_export
| $p_oid | is the oid of the log |
| $tmp | is the file |
Definition at line 861 of file class_database.php.
References db.
| Database::lo_unlink | ( | $p_oid | ) |
wrapper for the function pg_lo_unlink
| $p_oid | is the of oid |
Definition at line 821 of file class_database.php.
References db.
| Database::make_array | ( | $p_sql, | |
$p_null = 0 |
|||
| ) |
make a array with the sql
| $p_sql | sql statement, only the first two column will be returned in an array. The first col. is the label and the second the value |
| $p_null | if the array start with a null value |
Array
(
[0] => Array
(
[value] => 1
[label] => Marchandise A
)
[1] => Array
(
[value] => 2
[label] => Marchandise B
)
[2] => Array
(
[value] => 3
[label] => Marchandise C
)
) Definition at line 682 of file class_database.php.
| Database::make_list | ( | $sql, | |
$p_array = null |
|||
| ) |
create a string containing the value separated by comma for use in a SQL in statement
Definition at line 625 of file class_database.php.
References $f, $i, $idx, $p_array, $ret, $row, $sql, count(), get_array(), and trim().
|
static |
wrapper for the function pg_NumRows
| $ret | is the result of a exec_sql |
Definition at line 772 of file class_database.php.
References $ret.
Referenced by User\Admin(), Fiche\belong_ledger(), User\Check(), User\check_action(), Fiche\count_by_modele(), Periode\display_form_periode(), Fiche_Def\DisplayAttribut(), Acc_Account_Ledger\do_exist(), Fiche\empty_attribute(), Acc_Report\exist(), Follow_Up\export_csv(), Anc_Account\fetch_from_db(), Periode\find_periode(), Anc_Plan\get(), Fiche_Def\Get(), Fiche_Def_Ref\Get(), Acc_Reconciliation\get(), Document\get(), Fiche_Def\get_attr_min(), User\get_available_folder(), Fiche\get_bk_balance(), Supplier\get_by_account(), Customer\get_by_account(), Fiche_Def\get_by_category(), Acc_Operation\get_data(), Periode\get_date_limit(), Periode\get_exercice(), User\get_exercice(), Acc_Operation\get_internal(), Anc_Operation\get_jrid(), Acc_Operation\get_jrnx_detail(), User\get_ledger(), Acc_Account\get_lib(), Acc_Report\get_list(), Acc_Report\get_name(), Acc_Account_Ledger\get_name(), Acc_Ledger\get_name(), Anc_Plan\get_poste_analytique(), User\get_preference(), Acc_Ledger\get_propertie(), Acc_Report\get_row(), Acc_Ledger\get_row(), Fiche\get_row_result(), Acc_Account_Ledger\get_row_sql(), Acc_Ledger\get_rowSimple(), Acc_Account_Ledger\get_solde(), Acc_Account_Ledger\get_solde_detail(), Fiche\get_solde_detail(), Acc_Ledger\get_type(), Fiche_Def\GetAll(), Fiche_Def\getAttribut(), Fiche\getAttribut(), Fiche\GetByDef(), Stock\history(), html_min_page_start(), html_page_start(), isValid_deprecrated(), Acc_Ledger\list_operation(), Acc_Ledger\list_operation_to_reconcile(), Acc_Ledger\listing(), Profile_Menu\listing_profile(), Anc_Balance_Simple\load(), User\load(), Acc_Ledger_Info\load(), Forecast\load(), Forecast_Item\load(), Forecast_Cat\load(), Acc_Payment\load(), Acc_Parm_Code\load(), Todo_List\load(), Dossier\load(), Acc_Bilan\load(), Acc_Report\load(), Anc_Balance_Double\load(), Acc_Ledger_Info\load_all(), User\load_global_pref(), Document_modele\myList(), Fiche_Def\myList(), Own\Own(), query_to_csv(), Document_modele\Save(), gestion_purchase\search_by_jid(), Acc_Ledger_Info\search_id_internal(), Acc_Operation\seek_internal(), Document\Send(), ShowMenuFiche(), Html_Table\sql2table(), Profile_Menu\sub_menu(), Document_modele\update(), Fiche\update(), Anc_Operation\update_from_jrnx(), Customer\VatListing(), and Acc_Bilan\warning().
| Database::prepare | ( | $p_string, | |
| $p_sql | |||
| ) |
wrapper for the function pg_prepare
| $p_string | string name for pg_prepare function |
| $p_sql | is the sql to prepare |
Definition at line 831 of file class_database.php.
References db.
| Database::query_to_csv | ( | $ret, | |
| $aheader | |||
| ) |
with the handle of a successull query, echo each row into CSV and send it directly
| type | $ret | handle to a query |
| type | $aheader | double array, each item of the array contains a key type (num) and a key title |
Definition at line 903 of file class_database.php.
References $e, $i, $ret, $row, $seq, count(), fetch_array(), num_row(), and printf.
| Database::rollback | ( | ) |
rollback the current transaction
Definition at line 221 of file class_database.php.
References $Res, and exec_sql().
Referenced by execute_script(), and save_upload_document().
| Database::save_upload_document | ( | $seq | ) |
Save a "piece justificative".
| $seq | jr_grpt_id |
Definition at line 715 of file class_database.php.
References $_ENV, $cn, $r, $ret, db, echo_error(), exec_sql(), and rollback().
| Database::set_encoding | ( | $p_charset | ) |
Definition at line 110 of file class_database.php.
References db.
| Database::size | ( | ) |
return the number of rows found by the last query, synomym for count()
Definition at line 342 of file class_database.php.
Referenced by apply_patch().
| Database::start | ( | ) |
@ brief : start a transaction
Definition at line 205 of file class_database.php.
References $Res, and exec_sql().
| Database::status | ( | ) |
Definition at line 892 of file class_database.php.
References db.
|
static |
Definition at line 890 of file class_database.php.
| Database::verify | ( | ) |
Definition at line 106 of file class_database.php.
|
private |
database connection
Definition at line 36 of file class_database.php.
|
private |
return value
Definition at line 37 of file class_database.php.
Referenced by exec_sql(), execute(), fetch_all(), fetch_array(), fetch_result(), fetch_row(), make_list(), num_row(), query_to_csv(), and save_upload_document().