コード例 #1
0
 /**
  * Test for PMA_determineInsertOrEdit
  *
  * @return void
  */
 public function testDetermineInsertOrEdit()
 {
     $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
     $GLOBALS['dbi'] = $dbi;
     $_REQUEST['where_clause'] = '1';
     $_SESSION['edit_next'] = '1';
     $_REQUEST['ShowFunctionFields'] = true;
     $_REQUEST['ShowFieldTypesInDataEditView'] = true;
     $_REQUEST['after_insert'] = 'edit_next';
     $GLOBALS['cfg']['InsertRows'] = 2;
     $GLOBALS['cfg']['ShowSQL'] = false;
     $_REQUEST['default_action'] = 'insert';
     $responseMock = $this->getMockBuilder('PMA_Response')->disableOriginalConstructor()->setMethods(array('addHtml'))->getMock();
     $response = new ReflectionProperty('PMA_Response', '_instance');
     $response->setAccessible(true);
     $response->setValue(null, $responseMock);
     $result = PMA_determineInsertOrEdit('1', 'db', 'table');
     $this->assertEquals(array(false, null, array(1), null, array(null), array(null), false, "edit_next"), $result);
     // case 2
     unset($_REQUEST['where_clase']);
     unset($_SESSION['edit_next']);
     $_REQUEST['default_action'] = '';
     $result = PMA_determineInsertOrEdit(null, 'db', 'table');
     $this->assertEquals(array(false, '1', array(1), array(1), array(null), array(null), false, "edit_next"), $result);
 }
コード例 #2
0
ファイル: tbl_change.php プロジェクト: poush/phpmyadmin
require_once 'libraries/config/user_preferences.forms.php';
require_once 'libraries/config/page_settings.forms.php';
PageSettings::showGroup('Edit');
/**
 * Ensures db and table are valid, else moves to the "parent" script
 */
require_once 'libraries/db_table_exists.inc.php';
/**
 * functions implementation for this script
 */
require_once 'libraries/insert_edit.lib.php';
require_once 'libraries/transformations.lib.php';
/**
 * Determine whether Insert or Edit and set global variables
 */
list($insert_mode, $where_clause, $where_clause_array, $where_clauses, $result, $rows, $found_unique_key, $after_insert) = PMA_determineInsertOrEdit(isset($where_clause) ? $where_clause : null, $db, $table);
// Increase number of rows if unsaved rows are more
if (!empty($unsaved_values) && count($rows) < count($unsaved_values)) {
    $rows = array_fill(0, count($unsaved_values), false);
}
/**
 * file listing
*/
require_once 'libraries/file_listing.lib.php';
/**
 * Defines the url to return to in case of error in a sql statement
 * (at this point, $GLOBALS['goto'] will be set but could be empty)
 */
if (empty($GLOBALS['goto'])) {
    if (mb_strlen($table)) {
        // avoid a problem (see bug #2202709)