예제 #1
0
파일: Model.php 프로젝트: rickb838/scalr
 public function __call($name, $arguments)
 {
     if (!strncmp($name, "loadBy", 6) && count($arguments) > 0) {
         $name = lcfirst(substr($name, 6));
         $property = $this->findDbKeyByProperty($name);
         $value = $arguments[0];
         $loadFlag = !isset($arguments[1]) || isset($arguments[1]) && $arguments[1];
         if ($property && is_array($this->dbPropertyMap[$property]) && isset($this->dbPropertyMap[$property]['is_filter']) && $this->dbPropertyMap[$property]['is_filter']) {
             if ($loadFlag) {
                 $info = $this->db->getRow("SELECT * FROM {$this->dbTableName} WHERE {$property} = ? LIMIT 1", array($value));
                 if (!$info) {
                     throw new Exception(sprintf(_($this->dbMessageKeyNotFound), $value));
                 }
                 return $this->loadBy($info);
             } else {
                 return $this->db->getAll("SELECT * FROM {$this->dbTableName} WHERE {$property} = ?", array($value));
             }
         }
     }
     throw new Exception(_("Method '{$name}' of class '" . get_called_class() . "' not found"));
 }
예제 #2
0
 /**
  * {@inheritdoc}
  * @see Scalr\Upgrade.UpdateInterface::hasTableColumn()
  */
 public function hasTableColumn($table, $column)
 {
     $res = $this->db->getRow("SHOW COLUMNS FROM `" . $table . "` WHERE `field` = ?", array($column));
     return $res ? true : false;
 }