Difference between revisions of "API:EPrints/Database/mysql"

From EPrints Documentation
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- Pod2Wiki=_preamble_  
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/Database/mysql.pm|package_name=EPrints::Database::mysql}}[[Category:API|MYSQL]][[Category:API:EPrints/Database|MYSQL]][[Category:API:EPrints/Database/mysql|MYSQL]]<div><!-- Edit below this comment -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=perl_lib/EPrints/Database/mysql.pm|package_name=EPrints::Database::mysql}}[[Category:API|MYSQL]][[Category:API:EPrints/Database|MYSQL]][[Category:API:EPrints/Database/mysql|MYSQL]]<div><!-- Edit below this comment -->
  
  
Line 8: Line 8:
 
'''EPrints::Database::mysql''' - custom database methods for MySQL DB
 
'''EPrints::Database::mysql''' - custom database methods for MySQL DB
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_synopsis -->
 +
==SYNOPSIS==
 +
<source lang="perl">$c->{dbdriver} = 'mysql';
 +
# $c->{dbhost} = 'localhost';
 +
# $c->{dbport} = '3316';
 +
$c->{dbname} = 'myrepo';
 +
$c->{dbuser} = 'bob';
 +
$c->{dbpass} = 'asecret';
 +
# $c->{dbengine} = 'InnoDB';</source>
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=head_description -->
 
<!-- Pod2Wiki=head_description -->
 
==DESCRIPTION==
 
==DESCRIPTION==
 
MySQL database wrapper.
 
MySQL database wrapper.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
Foreign keys will be defined if you use a DB engine that supports them (e.g. InnoDB).
<span style='display:none'>User Comments</span>
+
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_mysql_specific_annoyances -->
 
<!-- Pod2Wiki=head_mysql_specific_annoyances -->
 
===MySQL-specific Annoyances===
 
===MySQL-specific Annoyances===
Line 32: Line 42:
 
MySQL is (by default) lax about truncation.
 
MySQL is (by default) lax about truncation.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_methods -->
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
==METHODS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<!-- Pod2Wiki=head_get_server_version -->
<span style='display:none'>User Comments</span>
+
<!-- Edit below this comment -->
+
 
+
 
+
<!-- Pod2Wiki= -->
+
</div>
+
<!-- Pod2Wiki=item_get_server_version -->
+
 
===get_server_version===
 
===get_server_version===
  
$version = $db-&gt;get_server_version
+
<source lang="perl">$version = $db->get_server_version
 +
 
 +
</source>
 
Return the database server version.
 
Return the database server version.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_create_counters -->
<!-- Pod2Wiki=item_create_counters -->
+
 
===create_counters===
 
===create_counters===
  
$n = $db-&gt;create_counters()
+
<source lang="perl">$n = $db->create_counters()
 +
 
 +
</source>
 
Create and initialise the counters.
 
Create and initialise the counters.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_has_table -->
<!-- Pod2Wiki=item_has_table -->
+
 
===has_table===
 
===has_table===
  
$boolean = $db-&gt;has_table( $tablename )
+
<source lang="perl">$boolean = $db->has_table( $tablename )
 +
 
 +
</source>
 
Return true if the a table of the given name exists in the database.
 
Return true if the a table of the given name exists in the database.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_has_column -->
<!-- Pod2Wiki=item_has_column -->
+
 
===has_column===
 
===has_column===
  
$boolean = $db-&gt;has_column( $tablename, $columnname )
+
<source lang="perl">$boolean = $db->has_column( $tablename, $columnname )
 +
 
 +
</source>
 
Return true if the a table of the given name has a column named $columnname in the database.
 
Return true if the a table of the given name has a column named $columnname in the database.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_has_counter -->
<!-- Pod2Wiki=item_has_counter -->
+
 
===has_counter===
 
===has_counter===
  
$success = $db-&gt;has_counter( $counter )
+
<source lang="perl">$success = $db->has_counter( $counter )
 +
 
 +
</source>
 
Returns true if $counter exists.
 
Returns true if $counter exists.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_counter_next -->
<!-- Pod2Wiki=item_counter_next -->
+
 
===counter_next===
 
===counter_next===
  
$n = $db-&gt;counter_next( $counter )
+
<source lang="perl">$n = $db->counter_next( $counter )
 +
 
 +
</source>
 
Return the next unused value for the named counter. Returns undef if  the counter doesn't exist.
 
Return the next unused value for the named counter. Returns undef if  the counter doesn't exist.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_counter_minimum -->
<!-- Pod2Wiki=item_counter_minimum -->
+
 
===counter_minimum===
 
===counter_minimum===
  
$db-&gt;counter_minimum( $counter, $value )
+
<source lang="perl">$db->counter_minimum( $counter, $value )
 +
 
 +
</source>
 
Ensure that the counter is set no lower that $value. This is used when importing eprints which may not be in scrict sequence.
 
Ensure that the counter is set no lower that $value. This is used when importing eprints which may not be in scrict sequence.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_counter_reset -->
<!-- Pod2Wiki=item_counter_reset -->
+
 
===counter_reset===
 
===counter_reset===
  
$db-&gt;counter_reset( $counter )
+
<source lang="perl">$db->counter_reset( $counter )
 +
 
 +
</source>
 
Return the counter. Use with cautiuon.
 
Return the counter. Use with cautiuon.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_copyright -->
 
<!-- Pod2Wiki=head_copyright -->
 
==COPYRIGHT==
 
==COPYRIGHT==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #ccepadding: 0em 1em 0em 1em; font-size: 80%; '>
+
Copyright 2000-2011 University of Southampton.
<span style='display:none'>User Comments</span>
+
 
 +
This file is part of EPrints http://www.eprints.org/.
 +
 
 +
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 +
 
 +
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 +
 
 +
You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.
 +
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=_postamble_ -->
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->
+
<!-- Edit below this comment -->

Latest revision as of 09:56, 22 January 2013

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.3, 3.2) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Database::mysql - custom database methods for MySQL DB


SYNOPSIS

$c->{dbdriver} = 'mysql';
# $c->{dbhost} = 'localhost';
# $c->{dbport} = '3316';
$c->{dbname} = 'myrepo';
$c->{dbuser} = 'bob';
$c->{dbpass} = 'asecret';
# $c->{dbengine} = 'InnoDB';


DESCRIPTION

MySQL database wrapper.

Foreign keys will be defined if you use a DB engine that supports them (e.g. InnoDB).


MySQL-specific Annoyances

MySQL does not support sequences.

MySQL is (by default) lax about truncation.


METHODS

get_server_version

$version = $db->get_server_version

Return the database server version.


create_counters

$n = $db->create_counters()

Create and initialise the counters.


has_table

$boolean = $db->has_table( $tablename )

Return true if the a table of the given name exists in the database.


has_column

$boolean = $db->has_column( $tablename, $columnname )

Return true if the a table of the given name has a column named $columnname in the database.


has_counter

$success = $db->has_counter( $counter )

Returns true if $counter exists.


counter_next

$n = $db->counter_next( $counter )

Return the next unused value for the named counter. Returns undef if the counter doesn't exist.


counter_minimum

$db->counter_minimum( $counter, $value )

Ensure that the counter is set no lower that $value. This is used when importing eprints which may not be in scrict sequence.


counter_reset

$db->counter_reset( $counter )

Return the counter. Use with cautiuon.


COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.