makeDB() static public method

return a field (array)
static public makeDB ( $row )
コード例 #1
0
ファイル: field_edit.php プロジェクト: soonick/poMMo
 $validator->setPost($_POST);
 $validator->addData('field_name', 'Other', false);
 $validator->addData('field_prompt', 'Other', false);
 $validator->addData('field_required', 'matchRegex', false, '!^(on|off)$!');
 $validator->addData('field_active', 'matchRegex', false, '!^(on|off)$!');
 if ($result = $validator->checkData()) {
     // __ FORM IS VALID
     // TODO -> Which below logic is better? the computed diff, or send all fields for update?
     /*
     // make a difference between updated & original field
     $update = array_diff_assoc(Pommo_Fields::makeDB($_POST),$field);
     // restore the ID
     $update['id'] = $field['id'];
     */
     // let MySQL do the difference processing
     $update = Pommo_Fields::makeDB($_POST);
     if (!Pommo_Fields::update($update)) {
         $json->fail('error updating field');
     }
     $json->add('callbackFunction', 'updateField');
     $json->add('callbackParams', $update);
     $json->success(Pommo::_T('Settings updated.'));
 } else {
     // __ FORM NOT VALID
     $fieldErrors = array();
     $errors = $validator->getErrors();
     foreach ($errors as $key => $val) {
         $fieldErrors[] = array('field' => $key, 'message' => $val);
     }
     $json->add('fieldErrors', $fieldErrors);
     $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
コード例 #2
0
ファイル: Pommo_Fields.php プロジェクト: soonick/poMMo
 static function get($p = array())
 {
     $defaults = array('active' => false, 'id' => null, 'byName' => false);
     $p = Pommo_Api::getParams($defaults, $p);
     $dbo = Pommo::$_dbo;
     $p['active'] = $p['active'] ? 'on' : null;
     $p['byName'] = $p['byName'] ? 'field_name' : 'field_ordering';
     $o = array();
     $query = "\n            SELECT *\n            FROM " . $dbo->table['fields'] . "\n            WHERE\n                1\n                [AND field_active='%S']\n                [AND field_id IN(%C)]\n            ORDER BY " . $p['byName'];
     $query = $dbo->prepare($query, array($p['active'], $p['id']));
     while ($row = $dbo->getRows($query)) {
         $o[$row['field_id']] = Pommo_Fields::makeDB($row);
     }
     return $o;
 }