Monday 31 August 2009 4:37:05 am
Hi there, Couldn't find any mysql_affected_rows() PHP function equivalent in the API, so I wrote a simple wrapper:
class mediaSELFTools
{
public static function mysqlAffectedRows( $dbConnection=null )
{
if ( !is_resource( $dbConnection ) )
{
$db = eZDB::instance();
$dbConnection = $db->DBConnection;
}
$ini = eZINI::instance();
$databaseImplementation = $ini->variable( 'DatabaseSettings', 'DatabaseImplementation' );
switch ( $databaseImplementation )
{
case 'ezmysql':
case 'mysql':
return mysql_affected_rows( $dbConnection );
break;
case 'ezmysqli':
case 'mysqli':
return mysqli_affected_rows( $dbConnection );
break;
}
throw new Exception( 'Unsupported or unknown database implementation: ' . $databaseImplementation . '!' );
}
}
1) Any recommendations? Can you see any risks? 2) Is there actually a similar function available already?
Cheers, Piotrek
--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu
|