check_column [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Check column matches criteria.
Uses the SQL DESC for retrieving the table info for the column. It will help understand the parameters, if you do more research on what column information is returned by the SQL statement. Pass in null to skip checking that criteria.
Column names returned from DESC table are case sensitive and are listed: Field Type Null Key Default Extra
Source
<?php
function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) {
global $wpdb;
$diffs = 0;
$results = $wpdb->get_results("DESC $table_name");
foreach ($results as $row ) {
if ($row->Field == $col_name) {
// got our column, check the params
if (($col_type != null) && ($row->Type != $col_type)) {
++$diffs;
}
if (($is_null != null) && ($row->Null != $is_null)) {
++$diffs;
}
if (($key != null) && ($row->Key != $key)) {
++$diffs;
}
if (($default != null) && ($row->Default != $default)) {
++$diffs;
}
if (($extra != null) && ($row->Extra != $extra)) {
++$diffs;
}
if ($diffs > 0) {
return false;
}
return true;
} // end if found our column
}
return false;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Click event on CheckColumn [Archive] - Sencha Forum
Nov 8, 2007 ... And here's my question: Is there any possibility to listen to a check or select event on a checkbox when using CheckColumn in this example: ...
www.sencha.com - Extjs checkColumn - Stack Overflow
I see the example in extjs but seems the checkColumn don't update ... in extjs4 you can do this. there is the 'checkchange' event, so you can have ...
stackoverflow.com - How to check if column exists in SQL Server table - Stack Overflow
Add a column if it doesn't exist to all tables? If does not exist,Add a column · Check Column Exist in a Table · If column exists query problem ...
stackoverflow.com - PHPXRef 0.7 : WordPress : /wp-admin/install-helper.php source
12 * 13 * <code> 14 * check_column('wp_links', 'link_description', 'mediumtext'); 15 * if (check_column($wpdb->comments, 'comment_author', 'tinytext')) 16 ...
phpxref.ftwr.co.uk