Solved

How to set default to "not null" when creating fields in phpmyadmin

Posted on 2006-11-09
9
589 Views
Last Modified: 2012-08-14
I'm using phpmyadmin to create the fields for an empty tablet.  For most of my fields I want to allow null values.  However, phpmyadmin always defaults to not null on the field creation screen.  Is there a fairly easy way to change this default?

I am currently using phpMyAdmin 2.6.3-pl1 and MySQL 4.1.13.

Since phpmyadmin is written in PHP, I suspect one could look through the code and fix this.  However, since this seem like something others might have wanted to do, I'm thinking maybe there is a configuration setting for phpmyadmin or someone has already figured out how to easily customize phpmyadmin's code to do this.
0
Comment
Question by:davidvieira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 11

Expert Comment

by:kblack05
ID: 17908274
If you take a look at the documentation, there are settings in the PhPMyAdmin config to handle how it creates tables...

http://wiki.cihar.com/pma/Category:Configuration

The latest stable version is phpMyAdmin 2.9.1 so you might consider upgrading the software. I think that this issue might have been changed.
0
 
LVL 1

Author Comment

by:davidvieira
ID: 18039799
Shortly after making my original post I did up date phpMyAdmin to 2.9.1 and that did not address the issue.

I looked at the documentation you mention specifically concentrating on the Configuration Directives page at http://wiki.cihar.com/pma/Config and did not find the solution to my question.  However, that document was particularly user friendly so it is possible that I missed something buried there.

kblack05,

I also did not find any information that seemed directly related to how phpMyAdmin creates tables.  Could you refer me to a more specific place in the documentation?

Thanks.
0
 
LVL 11

Accepted Solution

by:
kblack05 earned 500 total points
ID: 18040569
In phpmyadmin directory is a file called tbl_create.php which contains some lib references, and also some create references. Chances are what you are attempting to do will require recoding this file, particularly the areas where these types of statements occur:

// Builds the 'create table' statement
    $sql_query      = 'CREATE TABLE ' . PMA_backquote($table) . ' (' . $sql_query . ')';
    $query_cpy      = 'CREATE TABLE ' . PMA_backquote($table) . ' (' . $query_cpy . "\n" . ')';

    // Adds table type, character set and comments
    if (!empty($tbl_type) && ($tbl_type != 'Default')) {
        $sql_query .= ' ' . PMA_ENGINE_KEYWORD  . ' = ' . $tbl_type;
        $query_cpy .= "\n" . PMA_ENGINE_KEYWORD . ' = ' . $tbl_type;
    }
    if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
        $sql_query .= PMA_generateCharsetQueryPart($tbl_collation);
        $query_cpy .= "\n" . PMA_generateCharsetQueryPart($tbl_collation);
    }

    if (!empty($comment)) {
        $sql_query .= ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
        $query_cpy .= "\n" . 'COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
    }

    // Executes the query
    $error_create = false;
    $result    = PMA_DBI_try_query($sql_query) or $error_create = true;

    if ($error_create == false) {
        $sql_query = $query_cpy . ';';
        unset($query_cpy);
        $message   = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;

While I thought there was a config time option for this, it seems the public at large uses the default types in the creation, then uses the structure tool (tab) to modify any types.

0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 1

Author Comment

by:davidvieira
ID: 18634648
kblack05,

This is a little more complicated than I wanted to go at the moment, but thanks for the information.  I've accepted your answer and added it to my knowledge base for when I'm ready to try that.  

Maybe phpMyAdmin will add that as a config option before then.  :)

Thanks.
0
 
LVL 11

Expert Comment

by:kblack05
ID: 18634710
Sorry I wish there was a cleaner way. Perhaps there is another frontend you might consider. I think that there are some competitors to PhPMyAdmin which may work.

Looks like phpMyFlashAdmin has some interesting features, right on the front page it talks about default data structure options, though I have not used it.

http://www.bigwebmaster.com/2230.html
0
 
LVL 1

Author Comment

by:davidvieira
ID: 18659101
Thanks kblack05.  

I only read through the features list on the home page for phpMyFlashAdmin, but it looks like it might have the potential to replace Access in a database unit of a high-school class we teach here.  There is some interest in using mySQL instead of Access but for novices the graphical query and relationship tools in access are hard to beat.  If we could switch over to mySQL without loosing the simplicity we need for most students, it would be great for more advanced students who might be interested in doing something in PHP, which think is simpler than having to use VB or VBscript with an Access database. (I've done both some ADO programming in VB with access and PHP programming with mySQL.)
0
 
LVL 11

Expert Comment

by:kblack05
ID: 18663860
I believe that switching to mysql would be much more beneficial. It will be around long after MSAccess is no longer supported, and is constantly being updated. Agreed that the tools for Access are much more stylistic, and intutive for children to learn, which at the end of the day makes all the difference.

At one point there was a tool called "MySQLFront" http://www.mysqlfront.de/ but unfortunately someone decided the public did not have as much interest in ease of use as their pocketbook. :( This is a great example of what NOT to do in the open source world ). A replacement has come along which I know nothing about but may potentially investigate, which is called HeidiSQL http://www.heidisql.com/

Honestly I wish I had more answers and resources for you, sometimes the growth of Open Souce deals with pains caused by lack of attentiveness and greed. Overall it is my choice, and always will be, to advocate MySQL and other open source platforms such as Linux and FreeBSD. These software packages were built around performance, and gradually gravitate towards ease of use.

MS products are built with monetary return and ease of use in mind, and gradually gravitate towards availability based on affordability.

Perhaps in the not too distant future, the reality of the two will end up somewhere in between, though I always hope that it will be a free and unified open source world.
0
 
LVL 11

Expert Comment

by:kblack05
ID: 18663902
What do you know? HeidiSQL looks a lot like the MSAccess interface! In fact I think it has everything that MySQLFront had, and then some. Worth looking at.
0
 
LVL 1

Author Comment

by:davidvieira
ID: 18664444
Thanks!  I passed on the information to the teachers of the courses where Access is currently used.  The last three comments piggybacking on my original message is worth of a thread all it's own.  If I could grant you Expert's points for these recommendations too, I would.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question