Location: PHPKode > projects > DIY Blog > diy-blog/lib/creole/classes/creole/drivers/sqlite/SQLiteIdGenerator.php
<?php

require_once 'creole/IdGenerator.php';

/**
 * SQLite IdGenerator implimenation.
 *
 * @author    Hans Lellelid <hide@address.com>
 * @version   $Revision: 1.4 $
 * @package   creole.drivers.sqlite
 */
class SQLiteIdGenerator implements IdGenerator {
    
    /** Connection object that instantiated this class */
    private $conn;

    /**
     * Creates a new IdGenerator class, saves passed connection for use
     * later by getId() method.
     * @param Connection $conn
     */
    public function __construct(Connection $conn)
    {
        $this->conn = $conn;
    }
    
    /**
     * @see IdGenerator::isBeforeInsert()
     */
    public function isBeforeInsert()
    {
        return false;
    }    
    
    /**
     * @see IdGenerator::isAfterInsert()
     */
    public function isAfterInsert()
    {
        return true;
    }
       
    /**
     * @see IdGenerator::getIdMethod()
     */
    public function getIdMethod()
    {
        return self::AUTOINCREMENT;
    }
    
    /**
     * @see IdGenerator::getId()
     */
    public function getId($unused = null)
    {
        return sqlite_last_insert_rowid($this->conn->getResource());
    }
    
}

Return current item: DIY Blog