Example #1
0
 public function testPersist()
 {
     $jsonFilename = __DIR__ . '/workdir/persisting.json';
     file_put_contents($jsonFilename, '[]');
     $table = new Table($jsonFilename);
     $table->insert(['foo' => 'bar', 'baz' => 'bat']);
     $table->insert(['ab' => 'cd', 'ef' => 'gh']);
     $table->persist();
     $tableLoaded = new Table($jsonFilename);
     $this->assertSame(2, $tableLoaded->count());
     unlink($jsonFilename);
 }
Example #2
0
 public static function join($array, $separator, $startIndex = 0, $count = -1)
 {
     $string = "";
     //
     $end = $count == -1 ? Table::count($array) : $count;
     //
     for ($i = $startIndex; $i < $end; $i++) {
         if ($i == $end - 1) {
             $string .= $array[$i];
         } else {
             echo $string .= $array[$i] . $separator;
         }
     }
     //
     return $string;
 }
<?php

// This deletes the slider table ONLY if it is empty
if (Table::get('slider') !== false) {
    $table = new Table('slider');
    if ($table->count() < 1) {
        // no user data remaining. It's safe to drop
        Table::drop('slider');
    }
}
Example #4
0
	}
	$selector = 'dptpl';
	include template('manage_team_dptpl_edit');
}

elseif($action == 'delete'){
	$tpl_id = $_GET['id'];
	$tpl = Table::Fetch("dptpl",$tpl_id);

	$count = Table::count('dptpl_item',array('tpl_id'=>$tpl_id));
	if($count > 0){
		Session::Set('notice', '请先删除子项再删除模版');
		redirect( WEB_ROOT . "/manage/team/dptpl.php");	
	}

	$team_count = Table::count('team',array('dptpl_id'=>$tpl_id));
	if($team_count > 0){
		Session::Set('notice', '还有项目在使用,请处理后删除');
		redirect( WEB_ROOT . "/manage/team/dptpl.php");	
	}

	DB::Delete('dptpl',array('id'=>$tpl_id));
	Session::Set('notice', '删除成功');
		redirect( WEB_ROOT . "/manage/team/dptpl.php");	
}

/**
 * 点评项管理
 */ 
elseif($action == 'items'){
	$tpl_id = $_GET['id'];