mysql_affected_rows() wrapper

Author Message

Piotrek Karaƛ

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:17:55
Script start
Timing: Jan 18 2025 18:17:55
Module start 'layout'
Timing: Jan 18 2025 18:17:55
Module start 'content'
Timing: Jan 18 2025 18:17:55
Module end 'content'
Timing: Jan 18 2025 18:17:55
Script end

Main resources:

Total runtime0.0161 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 589.0313152.6250
Module start 'layout' 0.00690.0029 741.656339.4453
Module start 'content' 0.00970.0042 781.101689.4453
Module end 'content' 0.01390.0021 870.546930.3047
Script end 0.0160  900.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002515.5070140.0002
Check MTime0.00116.9937140.0001
Mysql Total
Database connection0.00117.102010.0011
Mysqli_queries0.002716.493830.0009
Looping result0.00000.093510.0000
Template Total0.001811.110.0018
Template load0.00084.917710.0008
Template processing0.00106.149410.0010
Override
Cache load0.00053.417510.0005
General
dbfile0.00021.363780.0000
String conversion0.00000.060840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs