Example #1
0
 public function getByID($fID)
 {
     $db = Loader::db();
     $f = new self();
     //Set properties
     $fData = $db->getRow("SELECT * FROM " . TABLE_FORMIFY_FORMS . " WHERE fID=? AND isDeleted != 1", array($fID));
     if ($fData['fID'] == $fID && $fID != 0) {
         foreach ($fData as $col => $val) {
             if ($val != '') {
                 $f->{$col} = $val;
             }
         }
         $f->magic = (bool) $f->magic;
         $f->captcha = (bool) $f->captcha;
         $f->submitActionPassRecordID = (bool) $f->submitActionPassRecordID;
         $f->ownerCanEdit = (bool) $f->ownerCanEdit;
         $f->ownerCanDelete = (bool) $f->ownerCanDelete;
         $f->oneRecordPerUser = (bool) $f->oneRecordPerUser;
         $f->recordCount = $f->getRecordCount();
         $f->permissions = $f->getPermissions();
         $f->fields = $f->getFields();
         return $f;
     } else {
         return false;
     }
 }
Example #2
0
 private function getFieldsFromElemMatch(array $elemMatch)
 {
     $fields = array();
     foreach ($elemMatch as $fieldName => $value) {
         if ($this->isOperator($fieldName, 'where')) {
             continue;
         }
         if ($this->isOperator($fieldName, array('and', 'or'))) {
             foreach ($value as $q) {
                 $test = new self($q);
                 $fields = array_merge($fields, $test->getFields());
             }
         } else {
             $fields[] = $fieldName;
         }
     }
     return $fields;
 }
Example #3
0
 public static function getPokemon($where = null, $order = null, $limit = null)
 {
     if (!is_null($where)) {
         $where = ' WHERE ' . $where;
     }
     if (!is_null($order)) {
         $order = ' ORDER BY ' . $order;
     }
     if (!is_null($limit)) {
         $limit = ' LIMIT ' . $limit;
     }
     $getPokemon = TPP::db()->query("SELECT\r\n\t\t\tp.`id`, p.`pokemon`, p.`name`, p.`level`, p.`nickname`, p.`gender`, p.`hold_item`, p.`status`, p.`box_id`, p.`poke_ball`, p.`comment`,\r\n\t\t\tGROUP_CONCAT(DISTINCT m.`name` SEPARATOR ',') as `moves`,\r\n\t\t\ts.`status` as `status_name`\r\n\t\t\tFROM `pokemon` p\r\n\t\t\tLEFT JOIN `move` m\r\n\t\t\tON m.`pokemon` = p.`id`\r\n\t\t\tJOIN `status` s\r\n\t\t\tON s.`id` = p.`status`\r\n\t\t\t" . $where . " GROUP BY p.`id`" . $order . $limit) or die(TPP::db()->error);
     while ($pok = $getPokemon->fetch_assoc()) {
         $newPokemon = new self();
         $newPokemon->setAttributes(array('id' => $pok['id'], 'name' => $newPokemon->setName($pok['name'], $pok['pokemon']), 'pokemon' => $newPokemon->setPokemon($pok['pokemon']), 'level' => $newPokemon->setLevel($pok['level']), 'nickname' => $newPokemon->setNickname($pok['nickname']), 'poke_ball' => $newPokemon->setPokeBall($pok['poke_ball']), 'gender' => $newPokemon->setGender($pok['gender']), 'hold_item' => $newPokemon->setHoldItem($pok['hold_item']), 'status' => $pok['status_name'], 'comment' => FuncHelp::getDateTime($pok['comment']), 'moves' => $newPokemon->setMoves($pok['moves'])));
         $newPokemon->setAttributes($newPokemon->getFields());
         $return[] = $newPokemon;
     }
     return $return;
 }
Example #4
0
 /** @return Am_DbSync_Table */
 static function createFromXml(SimpleXmlElement $table)
 {
     $t = new self((string) $table['name']);
     $t->oldNames = array_filter(array_map('trim', explode(",", $table["rename"])));
     foreach ($table->field as $field) {
         $t->addField(Am_DbSync_Field::createFromXml($field));
     }
     foreach ($table->index as $index) {
         $t->addIndex(Am_DbSync_Index::createFromXml($index));
     }
     foreach ($table->alter as $alter) {
         foreach ($alter->drop as $drop) {
             if ((string) $drop['field']) {
                 $t->addDropField((string) $drop['field']);
             }
             if ((string) $drop['index']) {
                 $t->addDropIndex((string) $drop['index']);
             }
         }
     }
     // check oldnames
     $fieldNames = array_keys($t->getFields());
     foreach ($t->getFields() as $field) {
         if ($field->getOldNames() && ($intersect = array_intersect($fieldNames, $field->getOldNames()))) {
             throw new Exception("XML file error - attempt to rename a field defined in schema /scheme/table[{$t->name}]/field=[{$intersect[0]}] to [{$field->getName()}]");
         }
     }
     $indexNames = array_keys($t->getIndexes());
     foreach ($t->getIndexes() as $index) {
         if ($index->getOldNames() && ($intersect = array_intersect($indexNames, $index->getOldNames()))) {
             throw new Exception("XML file error - attempt to rename an index defined in schema /scheme/table[{$t->name}]/index=[{$intersect[0]}] to [{$index->getName()}]");
         }
     }
     // create by data
     if ($table->data && $table->data->query) {
         foreach ($table->data->query as $query) {
             $t->data[] = (string) $query;
         }
     }
     // create by table_data
     if ($table->table_data && $table->table_data->row) {
         foreach ($table->table_data->row as $row) {
             $record = array();
             foreach ($row->field as $field) {
                 $record[(string) $field['name']] = (string) $field;
             }
             $t->data[] = $record;
         }
     }
     return $t;
 }
 /**
  * Function to get the instance of Company details module model
  * @return <Settings_Vtiger_CompanyDetais_Model> $moduleModel
  */
 public static function getInstance()
 {
     $moduleModel = new self();
     $db = PearDatabase::getInstance();
     $result = $db->pquery("SELECT * FROM vtiger_organizationdetails", array());
     if ($db->num_rows($result) == 1) {
         $moduleModel->setData($db->query_result_rowdata($result));
         $moduleModel->set('id', $moduleModel->get('organization_id'));
     }
     $moduleModel->getFields();
     return $moduleModel;
 }