コード例 #1
0
ファイル: Table.php プロジェクト: BaguettePHP/phactory
 public function __construct($singular_name, $pluralize = true, Phactory $phactory)
 {
     $this->_phactory = $phactory;
     $this->_db_util = DbUtilFactory::getDbUtil($phactory);
     $this->_singular = $singular_name;
     if ($pluralize) {
         $this->_name = Inflector::pluralize($singular_name);
     } else {
         $this->_name = $singular_name;
     }
 }
コード例 #2
0
ファイル: Blueprint.php プロジェクト: BaguettePHP/phactory
 /**
  * Truncate table in the database.
  */
 public function recall()
 {
     $db_util = DbUtilFactory::getDbUtil($this->_phactory);
     $db_util->disableForeignKeys();
     try {
         $sql = "DELETE FROM {$this->_table->getName()}";
         $this->_phactory->getConnection()->exec($sql);
     } catch (Exception $e) {
     }
     foreach ($this->_associations as $association) {
         if ($association instanceof Association\ManyToMany) {
             try {
                 $sql = "DELETE FROM `{$association->getJoinTable()}`";
                 $this->_phactory->getConnection()->exec($sql);
             } catch (Exception $e) {
             }
         }
     }
     $db_util->enableForeignKeys();
 }