Пример #1
0
 public function get($name, $cache_level = NULL)
 {
     $fname = $name . '.' . $cache_level;
     $expiry_condition = $cache_level == Registry::cacheLevel('time') ? db_quote(" AND expiry > ?i", TIME) : '';
     Db::$raw = true;
     $res = Db::getRow("SELECT data, expiry FROM ?:cache WHERE name = ?s AND company_id = ?i ?p", $fname, $this->_company_id, $expiry_condition);
     if (!empty($name) && !empty($res)) {
         $_cache_data = !empty($res['data']) ? @unserialize($res['data']) : false;
         if ($_cache_data !== false) {
             return array($_cache_data);
         }
         // clean up the cache
         Db::$raw = true;
         Db::query("DELETE FROM ?:cache WHERE name = ?s AND company_id = ?i", $fname, $this->_company_id);
     }
     return false;
 }
Пример #2
0
/**
 * Get auto increment value for table
 *
 * @param string $table - database table
 * @return integer - auto increment value
 */
function db_get_next_auto_increment_id($table)
{
    $table_status = Database::getRow("SHOW TABLE STATUS LIKE '?:{$table}'");
    return !empty($table_status['Auto_increment']) ? $table_status['Auto_increment'] : $table_status['AUTO_INCREMENT'];
}