コード例 #1
0
 /**
  * Create indexes and uniques specified in class map 
  * @param epClassMap $cm The class map 
  * @param bool Whether to force to create table or not
  * @return bool
  */
 public function index($cm, $create = false)
 {
     // check if class is abstract
     if ($cm->isAbstract()) {
         // if so, no need to actually create
         return true;
     }
     // tabe not exists?
     if (!$this->_tableExists($cm->getTable())) {
         // done if -not- forced to create
         if (!$force) {
             return true;
         }
         // create (includes index creation. done.)
         return $this->create($cm, true);
     }
     // check if index exists already
     if (!($curIndexes = $this->checkIndex($cm))) {
         return false;
     }
     // preapre sql statement for creating index
     $sqls = epObj2Sql::sqlCreateIndex($this, $cm, $curIndexes);
     if (!$sqls) {
         return false;
     }
     // execute sql
     return $r = $this->_execute($sqls);
 }