コード例 #1
0
ファイル: AkDbSchemaCache.php プロジェクト: joeymetal/v1
    function _set($type, $config, $environment = AK_ENVIRONMENT, $force = false, $var_export = false)
    {
        if ($var_export === false) {
            $cache = serialize($config);
        } else {
            $cacheStr = var_export($config,true);
            $cache = <<<EOF
<?php
\$cache = $cacheStr;
return \$cache;
?>
EOF;
        }
        $cacheFileName = AkDbSchemaCache::_generateCacheFileName($type,$environment);
        $cacheDir = dirname($cacheFileName);
        
        if (!file_exists($cacheDir)) {
            $oldumask = umask();
            umask(0);
            $res = @mkdir($cacheDir,0777,true);
            if (!$res) {
                trigger_error(Ak::t('Could not create config cache dir %dir',array('%dir'=>$cacheDir)),E_USER_ERROR);
            }
            umask($oldumask);
        }
        $fh = fopen($cacheFileName,'w+');
        if ($fh) {
            fputs($fh,$cache);
            fclose($fh);
            @chmod($cacheFileName,0777);
        } else {
            trigger_error(Ak::t('Could not create dbschema cache file %file',array('%file'=>$cacheFileName)),E_USER_ERROR);
        }
        AkDbSchemaCache::_get($type, $environment, false, $config);
    }