[ Index ] |
|
Code source de Claroline 188 |
1 <?php // $Id: class.clarodbconnection.php,v 1.10 2007/02/15 17:36:46 mathieu Exp $ 2 if ( count( get_included_files() ) == 1 ) die( '---' ); 3 4 // vim: expandtab sw=4 ts=4 sts=4: 5 6 /** 7 * CLAROLINE 8 * 9 * @version 1.8 $Revision: 1.10 $ 10 * 11 * @copyright 2001-2006 Universite catholique de Louvain (UCL) 12 * 13 * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE 14 * This program is under the terms of the GENERAL PUBLIC LICENSE (GPL) 15 * as published by the FREE SOFTWARE FOUNDATION. The GPL is available 16 * through the world-wide-web at http://www.gnu.org/copyleft/gpl.html 17 * 18 * @author Frederic Minne <zefredz@gmail.com> 19 * 20 * @package Wiki 21 */ 22 23 require_once dirname(__FILE__) . "/class.dbconnection.php"; 24 25 class ClarolineDatabaseConnection extends DatabaseConnection 26 { 27 28 function ClarolineDatabaseConnection() 29 { 30 // use only in claroline tools 31 } 32 33 function setError( $errmsg = '', $errno = 0 ) 34 { 35 if ( $errmsg != '' ) 36 { 37 $this->error = $errmsg; 38 $this->errno = $errno; 39 } 40 else 41 { 42 $this->error = ( claro_sql_error() !== false ) ? claro_sql_error() : 'Unknown error'; 43 $this->errno = ( claro_sql_errno() !== false ) ? claro_sql_errno() : 0; 44 } 45 46 $this->connected = false; 47 } 48 49 function connect() 50 { 51 52 } 53 54 function close() 55 { 56 57 } 58 59 function executeQuery( $sql ) 60 { 61 claro_sql_query( $sql ); 62 63 if( claro_sql_errno() != 0 ) 64 { 65 $this->setError(); 66 67 return 0; 68 } 69 70 return claro_sql_affected_rows( ); 71 } 72 73 function getAllObjectsFromQuery( $sql ) 74 { 75 $result = claro_sql_query( $sql ); 76 77 if ( @mysql_num_rows( $result ) > 0 ) 78 { 79 $ret= array(); 80 81 while( ( $item = @mysql_fetch_object( $result ) ) != false ) 82 { 83 $ret[] = $item; 84 } 85 } 86 else 87 { 88 $this->setError(); 89 90 @mysql_free_result( $result ); 91 92 return null; 93 } 94 95 @mysql_free_result( $result ); 96 97 return $ret; 98 } 99 100 function getObjectFromQuery( $sql ) 101 { 102 $result = claro_sql_query( $sql ); 103 104 if ( ( $item = @mysql_fetch_object( $result ) ) != false ) 105 { 106 @mysql_free_result( $result ); 107 108 return $item; 109 } 110 else 111 { 112 $this->setError(); 113 114 @mysql_free_result( $result ); 115 return null; 116 } 117 } 118 119 function getAllRowsFromQuery( $sql ) 120 { 121 $result = claro_sql_query( $sql ); 122 123 if ( @mysql_num_rows( $result ) > 0 ) 124 { 125 $ret= array(); 126 127 while ( ( $item = @mysql_fetch_array( $result ) ) != false ) 128 { 129 $ret[] = $item; 130 } 131 } 132 else 133 { 134 $this->setError(); 135 136 @mysql_free_result( $result ); 137 138 return null; 139 } 140 141 @mysql_free_result( $result ); 142 143 return $ret; 144 } 145 146 function getRowFromQuery( $sql ) 147 { 148 $result = claro_sql_query( $sql ); 149 150 if ( ( $item = @mysql_fetch_array( $result ) ) != false ) 151 { 152 @mysql_free_result( $result ); 153 154 return $item; 155 } 156 else 157 { 158 $this->setError(); 159 160 @mysql_free_result( $result ); 161 162 return null; 163 } 164 } 165 166 function queryReturnsResult( $sql ) 167 { 168 $result = claro_sql_query( $sql ); 169 170 if ( claro_sql_errno() == 0 ) 171 { 172 173 if ( @mysql_num_rows( $result ) > 0 ) 174 { 175 @mysql_free_result( $result ); 176 177 return true; 178 } 179 else 180 { 181 @mysql_free_result( $result ); 182 183 return false; 184 } 185 } 186 else 187 { 188 $this->setError(); 189 190 return false; 191 } 192 } 193 194 function getLastInsertID() 195 { 196 if ( $this->hasError() ) 197 { 198 return 0; 199 } 200 else 201 { 202 return claro_sql_insert_id(); 203 } 204 } 205 } 206 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 14:38:42 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |