Procedure call in ORDS - oracle

When I call the procedure through PL/SQL , it works fine but when i call the same through ORDS with same input , it throws the below error. Please correct me.
SQL Error Code: 6550, Error Message: ORA-06550: line 2, column 8: PLS-00306: wrong number or types of arguments in call to ‘BALA_payc_details’ ORA-06550: line 2, column 8: PL/SQL:
Below is complete code
BEGIN
ORDS.ENABLE_SCHEMA(
p_enabled => TRUE,
p_schema => ‘TestAPI’,
p_url_mapping_type => ‘BASE_PATH’,
p_url_mapping_pattern => ‘TestAPI’,
p_auto_rest_auth => FALSE);
ORDS.DEFINE_MODULE(
p_module_name => ‘pay’,
p_base_path => ‘/pay/’,
p_items_per_page => 0,
p_status => ‘PUBLISHED’,
p_comments => NULL);
ORDS.DEFINE_TEMPLATE(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_priority => 0,
p_etag_type => ‘HASH’,
p_etag_query => NULL,
p_comments => NULL);
ORDS.DEFINE_HANDLER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_source_type => ‘plsql/block’,
p_items_per_page => 5,
p_mimes_allowed => ”,
p_comments => NULL,
p_source =>
‘begin
TCTD.PKG_BALA.BALA_payc_details(
finp_type => :nptype,
finp_value => :npvalue,
fIsPaycard => :card,
p_verrcode => :code,
p_verrdesc => :description,
v_refcur => :v_refcur);
end;’
);
ORDS.DEFINE_PARAMETER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_name => ‘nptype’,
p_bind_variable_name => ‘nptype’,
p_source_type => ‘HEADER’,
p_param_type => ‘STRING’,
p_access_method => ‘IN’,
p_comments => NULL);
ORDS.DEFINE_PARAMETER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_name => ‘npvalue’,
p_bind_variable_name => ‘npvalue’,
p_source_type => ‘HEADER’,
p_param_type => ‘STRING’,
p_access_method => ‘IN’,
p_comments => NULL);
ORDS.DEFINE_PARAMETER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_name => ‘card’,
p_bind_variable_name => ‘card’,
p_source_type => ‘HEADER’,
p_param_type => ‘STRING’,
p_access_method => ‘IN’,
p_comments => NULL);
ORDS.DEFINE_PARAMETER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_name => ‘code’,
p_bind_variable_name => ‘code’,
p_source_type => ‘RESPONSE’,
p_param_type => ‘INT’,
p_access_method => ‘OUT’,
p_comments => NULL);
ORDS.DEFINE_PARAMETER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_name => ‘description’,
p_bind_variable_name => ‘description’,
p_source_type => ‘RESPONSE’,
p_param_type => ‘STRING’,
p_access_method => ‘OUT’,
p_comments => NULL);
ORDS.DEFINE_PARAMETER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_name => ‘v_refcur’,
p_bind_variable_name => ‘v_refcur’,
p_source_type => ‘RESPONSE’,
p_param_type => ‘RESULTSET’,
p_access_method => ‘OUT’,
p_comments => NULL);
COMMIT;
END;
Postman JSON Input…
{
“nptype” : “S”,
“nptypevalue” : “23456”,
“card” : “Y”
}
This throws error ORA-06550: line 2, column 8: PLS-00306: wrong number or types of arguments in call to ‘ ORA-06550: line 2, column 8: PLS-00306: wrong number or types of arguments in call to ‘BALA_payc_details’’
2.. When I call the same procedure with below input in PL/SQL , it is working fine.
DECLARE
verrcode Number(10);
verrdesc varchar2(100);
v_refcur SYS_REFCURSOR;
BEGIN
TCTD.PKG_BALA.BALA_payc_details (‘S’,’23456′,’Y’,verrcode,verrdesc,v_refcur);
END;
Please let me know what I need to change in ORDS call?

The code you are executing successfully in pl/sql is NOT the same code that is in the handler. If you change the hander to the following they both are the same. Note that I copied this code from your question and the single quotes will not be valid when you copy this code back into your ide. Replace the quotes with proper single quotes.
ORDS.DEFINE_HANDLER(
p_module_name => ‘pay’,
p_pattern => ‘/inquiry’,
p_method => ‘POST’,
p_source_type => ‘plsql/block’,
p_items_per_page => 5,
p_mimes_allowed => ”,
p_comments => NULL,
p_source =>
‘DECLARE
verrcode Number(10);
verrdesc varchar2(100);
v_refcur SYS_REFCURSOR;
BEGIN
TCTD.PKG_BALA.BALA_payc_details(
finp_type => :nptype,
finp_value => :npvalue,
fIsPaycard => :card,
p_verrcode => verrcode,
p_verrdesc => verrdesc,
v_refcur => v_refcur);
end;’
);
But... with a ref cursor as bind variable that is probably never going to work. A ref cursor is an internal oracle type - how do you plan to pass that as part of a json payload ?

Related

Modify Custom Taxonomy slug with CPT slug

Hi please check my requirement bellow.
First of all, I have registered a CPT "directory" with a slug name "directory". Also, I have registered a custom taxonomy "business_category". I want to below permalink structure.
CPT Archive link: www.domain.com/directory/
Taxonomy link: www.domain.com/directory/category/TAXONOMY_NAME/
CPT Single Page: www.domain.com/directory/POST_NAME
So, I have used the Below code.
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
$this->PT = 'cc-directory';
$this->name = 'Directory';
$this->singular_name = 'Directory';
$this->slug = 'directory';
}
public function register_post_type() {
// Get supported features for Directory post type
$supports = apply_filters('cc_directory_supports', array('editor', 'title','thumbnail'));
$labels = array(
'name' => $this->name,
'singular_name' => $this->singular_name,
'add_new' => 'Add New',
'add_new_item' => 'Add New ' . $this->singular_name,
'edit_item' => 'Edit ' . $this->singular_name,
'new_item' => 'New ' . $this->singular_name,
'all_items' => 'All ' . $this->name,
'view_item' => 'View ' . $this->name,
'search_items' => 'Search ' . $this->name,
'not_found' => 'No ' . strtolower($this->name) . ' found',
'not_found_in_trash' => 'No ' . strtolower($this->name) . ' found in Trash',
'parent_item_colon' => '',
'menu_name' => $this->name
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $this->slug ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => 11,
'menu_icon' => 'dashicons-book',
'supports' => $supports,
'yarpp_support' => true
);
register_post_type( $this->PT, $args );
$plural_label = 'Categories';
$singular_label = 'Category';
register_taxonomy(
'business_category',
$this->PT,
array(
'label' => $plural_label,
'labels' => array(
'name' => $plural_label,
'singular_name' => $singular_label,
'all_items' => sprintf(__('All %s', 'claritycloud-directory'), $plural_label),
'edit_item' => sprintf(__('Edit %s', 'claritycloud-directory'), $singular_label),
'view_item' => sprintf(__('View %s', 'claritycloud-directory'), $singular_label),
'update_item' => sprintf(__('Update %s', 'claritycloud-directory'), $singular_label),
'add_new_item' => sprintf(__('Add New %s', 'claritycloud-directory'), $singular_label),
'new_item_name' => sprintf(__('New %s Name', 'claritycloud-directory'), $singular_label),
'popular_items' => sprintf(__('Popular %s', 'claritycloud-directory'), $plural_label),
'search_items' => sprintf(__('Search %s', 'claritycloud-directory'), $plural_label),
),
'public' => true,
'show_ui' => true,
'show_in_rest' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'business-category'),
)
);
}
Right now my URLs are :
http://localhost/demo-project/directory/
http://localhost/demo-project/business-category/antiques/
http://localhost/demo-project/directory/a-lil-bit-of-sas/
It will be like below:
http://localhost/demo-project/directory/
http://localhost/demo-project/directory/category/antiques/
http://localhost/demo-project/directory/a-lil-bit-of-sas/
Just need to modify the above 2nd URL.
Can anyone please advise me?
Thanks,
Subhankar
Finally, I got the solution here:
add_action('init', 'cpt_resources');
function cpt_resources() {
$labels = array(
'name' => _x('Resources', 'snt'),
'singular_name' => _x('Resource', 'snt'),
'add_new' => _x('Add Resource', 'snt'),
'add_new_item' => __('Add Resource'),
'edit_item' => __('Edit Resource'),
'new_item' => __('New Resource'),
'view_item' => __('View Resource'),
'search_items' => __('Search Resources'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'taxonomies' => array('resource_type'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'resources' ),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','thumbnail', 'editor' ),
);
register_post_type( 'resources_post_type' , $args );
}
function resource_type() {
$labels = array(
'name' => _x( 'Resource Types', 'Taxonomy General Name', 'snt' ),
'singular_name' => _x( 'Resource Type', 'Taxonomy Singular Name', 'snt' ),
'menu_name' => __( 'Resource Types', 'snt' ),
'all_items' => __( 'All Items', 'snt' ),
'parent_item' => __( 'Parent Item', 'snt' ),
'parent_item_colon' => __( 'Parent Item:', 'snt' ),
'new_item_name' => __( 'New Item Name', 'snt' ),
'add_new_item' => __( 'Add New Item', 'snt' ),
'edit_item' => __( 'Edit Item', 'snt' ),
'update_item' => __( 'Update Item', 'snt' ),
'view_item' => __( 'View Item', 'snt' ),
'separate_items_with_commas' => __( 'Separate items with commas', 'snt' ),
'add_or_remove_items' => __( 'Add or remove items', 'snt' ),
'choose_from_most_used' => __( 'Choose from the most used', 'snt' ),
'popular_items' => __( 'Popular Items', 'snt' ),
'search_items' => __( 'Search Items', 'snt' ),
'not_found' => __( 'Not Found', 'snt' ),
'no_terms' => __( 'No items', 'snt' ),
'items_list' => __( 'Items list', 'snt' ),
'items_list_navigation' => __( 'Items list navigation', 'snt' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => array('slug' => 'resources/category')
);
register_taxonomy( 'resource_type', array( 'resources_post_type' ), $args );
}
add_action( 'init', 'resource_type', 0 );
function resources_cpt_generating_rule($wp_rewrite) {
$rules = array();
$terms = get_terms( array(
'taxonomy' => 'resource_type',
'hide_empty' => false,
) );
$post_type = 'resources_post_type';
foreach ($terms as $term) {
$rules['resources/category/' . $term->slug . '/([^/]*)$'] = 'index.php?post_type=' . $post_type. '&resources_post_type=$matches[1]&name=$matches[1]';
}
// merge with global rules
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_filter('generate_rewrite_rules', 'resources_cpt_generating_rule');
Result :
http://localhost/demo-wp/resources/
http://localhost/demo-wp/resources/category/test-resources/
http://localhost/demo-wp/resources/final-check/

Magento 2 Translation Extension by Magefan error

After deploy Magento 2 Translation Extension by Magefan i got following error
{"0":"Warning: class_implements(): Class TranslationGridDataProvider does not exist and could not be loaded in \/home\/419982.cloudwaysapps.com\/vftydjkdjd\/public_html\/vendor\/magento\/framework\/Code\/Reader\/ClassReader.php on line 71","1":"<pre>#1 class_implements('TranslationGridD...') called at [vendor\/magento\/framework\/Code\/Reader\/ClassReader.php:71]\n#2 Magento\\Framework\\Code\\Reader\\ClassReader->getParents('TranslationGridD...') called at [vendor\/magento\/framework\/View\/Element\/UiComponent\/Argument\/Interpreter\/ConfigurableObject.php:118]\n#3 Magento\\Framework\\View\\Element\\UiComponent\\Argument\\Interpreter\\ConfigurableObject->getParents('TranslationGridD...') called at [vendor\/magento\/framework\/View\/Element\/UiComponent\/Argument\/Interpreter\/ConfigurableObject.php:96]\n#4 Magento\\Framework\\View\\Element\\UiComponent\\Argument\\Interpreter\\ConfigurableObject->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [generated\/code\/Magento\/Framework\/Data\/Argument\/InterpreterInterface\/Proxy.php:95]\n#5 Magento\\Framework\\Data\\Argument\\InterpreterInterface\\Proxy->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [vendor\/magento\/framework\/Data\/Argument\/Interpreter\/Composite.php:61]\n#6 Magento\\Framework\\Data\\Argument\\Interpreter\\Composite->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [vendor\/magento\/module-ui\/Config\/Data.php:164]\n#7 Magento\\Ui\\Config\\Data-
Please make sure that when installing Magento 2 Translation Extension you followed the installation instructions, especially the step
php bin/magento setup:di:compile

CodeIgniter: The filetype you are attempting to upload is not allowed. isset($this->_mimes[$ext]) is always null

I have spent hours for this problem, but I have no idea how to fix it. I am having an error message when I try to upload an image. The error message is "The filetype you are attempting to upload is not allowed." But I don't think filetype is causing this problem. I found out that ! $this->upload->do_upload('image') is always false. and I found out that is because $this->_mimes[$ext]) (which is in the "system/libraries/Upload.php" file.) always brings me NULL.
When I tested out my function, I tried var_dump($this->file_type); and got "image/jpeg".
I also tried var_dump($ext); and got "jpg".
This is a part of Image.php file.
<?php echo form_open_multipart('/image/index');?>
<fieldset>
<legend>Upload Image</legend>
<div><label>File: </label><input id="image" type="file" name="image" /></div>
<div><label>Title: </label><input id="title" type="text" name="title" /></div>
<div class="error">
<?php echo $error; ?>
</div>
</fieldset>
<div class="form_line"><input id="image_submit" type="submit" value="Upload Picture" class="submit" /></div>
</form>
This is a part of Picture.php file.
function index()
{
$config['upload_path'] ='./uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = 40960000;
$config['max_width'] = 0;
$config['max_height'] = 0;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('image'))
{
$page_data = array('files' => $file_send, 'error' => $this->upload->display_errors());
$this->load->view('media/image_upload', $page_data);
}
else {...}
}
Here is where I found the null value. This is a CodeIgniter code.
public function is_allowed_filetype($ignore_mime = FALSE)
{
if ($this->allowed_types === '*')
{
return TRUE;
}
if (empty($this->allowed_types) OR ! is_array($this->allowed_types))
{
$this->set_error('upload_no_file_types', 'debug');
return FALSE;
}
$ext = strtolower(ltrim($this->file_ext, '.'));
if ( ! in_array($ext, $this->allowed_types, TRUE))
{
return FALSE;
}
// Images get some additional checks
if (in_array($ext, array('gif', 'jpg', 'jpeg', 'jpe', 'png'), TRUE) && #getimagesize($this->file_temp) === FALSE)
{
return FALSE;
}
if ($ignore_mime === TRUE)
{
return TRUE;
}
// isset($this->_mimes[$ext]) is always null
if (isset($this->_mimes[$ext]))
{
return is_array($this->_mimes[$ext])
? in_array($this->file_type, $this->_mimes[$ext], TRUE)
: ($this->_mimes[$ext] === $this->file_type);
}
return FALSE;
}
If you have any suggestion for this problem, I will greatly appreciate it.
I am sorry if something is not clear. If you need more codes, I will provide them for sure.
EDIT
I am adding mimes.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types. It is used by the
| Upload class to help identify allowed file types.
|
*/
$mimes = array( 'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
'bin' => 'application/macbinary',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'psd' => 'application/x-photoshop',
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => array('application/pdf', 'application/x-download'),
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'php' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => array('audio/mpeg', 'audio/mpg'),
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'png' => array('image/png', 'image/x-png'),
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => array('text/plain', 'text/x-log'),
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822'
);
/* End of file mimes.php */
/* Location: ./system/application/config/mimes.php */
I figured this out. It was because of the mimes.php file. Previously, CodeIgniter provided mimes.php with this format. $mimes = array( 'hqx' => 'application/mac-binhex40',.... However, the current CodeIgniter changed the format as return array(
'hqx' => array('application/mac-binhex40', .... When I updated the framework, I didn't update mimes.php file. Thank you so much Alex for providing me a hint!
Here is the modified mimes.php.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types. It is used by the
| Upload class to help identify allowed file types.
|
*/
return array(
'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => array('application/octet-stream', 'application/x-msdownload'),
'class' => 'application/octet-stream',
'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
'ai' => array('application/pdf', 'application/postscript'),
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => array('application/x-javascript', 'text/plain'),
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
'z' => 'application/x-compress',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
'aif' => array('audio/x-aiff', 'audio/aiff'),
'aiff' => array('audio/x-aiff', 'audio/aiff'),
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
'gif' => 'image/gif',
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'png' => array('image/png', 'image/x-png'),
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => array('text/css', 'text/plain'),
'html' => array('text/html', 'text/plain'),
'htm' => array('text/html', 'text/plain'),
'shtml' => array('text/html', 'text/plain'),
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => array('text/plain', 'text/x-log'),
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => array('application/xml', 'text/xml', 'text/plain'),
'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
'movie' => 'video/x-sgi-movie',
'doc' => array('application/msword', 'application/vnd.ms-office'),
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
'dot' => array('application/msword', 'application/vnd.ms-office'),
'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822',
'json' => array('application/json', 'text/json'),
'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
'p10' => array('application/x-pkcs10', 'application/pkcs10'),
'p12' => 'application/x-pkcs12',
'p7a' => 'application/x-pkcs7-signature',
'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
'p7r' => 'application/x-pkcs7-certreqresp',
'p7s' => 'application/pkcs7-signature',
'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
'crl' => array('application/pkix-crl', 'application/pkcs-crl'),
'der' => 'application/x-x509-ca-cert',
'kdb' => 'application/octet-stream',
'pgp' => 'application/pgp',
'gpg' => 'application/gpg-keys',
'sst' => 'application/octet-stream',
'csr' => 'application/octet-stream',
'rsa' => 'application/x-pkcs7',
'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
'3g2' => 'video/3gpp2',
'3gp' => array('video/3gp', 'video/3gpp'),
'mp4' => 'video/mp4',
'm4a' => 'audio/x-m4a',
'f4v' => array('video/mp4', 'video/x-f4v'),
'flv' => 'video/x-flv',
'webm' => 'video/webm',
'aac' => 'audio/x-acc',
'm4u' => 'application/vnd.mpegurl',
'm3u' => 'text/plain',
'xspf' => 'application/xspf+xml',
'vlc' => 'application/videolan',
'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
'au' => 'audio/x-au',
'ac3' => 'audio/ac3',
'flac' => 'audio/x-flac',
'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'),
'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
'ics' => 'text/calendar',
'ical' => 'text/calendar',
'zsh' => 'text/x-scriptzsh',
'7z' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
'7zip' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
'vcf' => 'text/x-vcard',
'srt' => array('text/srt', 'text/plain'),
'vtt' => array('text/vtt', 'text/plain'),
'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
'odc' => 'application/vnd.oasis.opendocument.chart',
'otc' => 'application/vnd.oasis.opendocument.chart-template',
'odf' => 'application/vnd.oasis.opendocument.formula',
'otf' => 'application/vnd.oasis.opendocument.formula-template',
'odg' => 'application/vnd.oasis.opendocument.graphics',
'otg' => 'application/vnd.oasis.opendocument.graphics-template',
'odi' => 'application/vnd.oasis.opendocument.image',
'oti' => 'application/vnd.oasis.opendocument.image-template',
'odp' => 'application/vnd.oasis.opendocument.presentation',
'otp' => 'application/vnd.oasis.opendocument.presentation-template',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
'odt' => 'application/vnd.oasis.opendocument.text',
'odm' => 'application/vnd.oasis.opendocument.text-master',
'ott' => 'application/vnd.oasis.opendocument.text-template',
'oth' => 'application/vnd.oasis.opendocument.text-web'
);

Set default (current datetime) to table column - CodeIgniter 3 migration

I have this migration:
public function up(){
$this->dbforge->add_field([
'id'=>['type'=>'int', 'unique'=>true, 'unsigned'=>true,'auto_increment'=>true],
'email'=>['type'=>'varchar', 'constraint'=>200, 'null'=>true],
'password'=>['type'=>'varchar', 'constraint'=>250],
'created_at'=>['type'=>'datetime', 'default' => 'CURRENT_TIMESTAMP'],
]);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('users', TRUE);
}
I am trying to set table with column created_at with default value - current datetime.
I am using 'default' => 'CURRENT_TIMESTAMP', but I am getting this error:
Invalid default value for 'created_at' ....
NOT NULL, created_at datetime NOT NULL DEFAULT 'CURRENT_TIMESTAMP',
I am using CodeIgniter 3 with MySQL.
this worked for me, and is valid in the documentation
Passing strings as fields If you know exactly how you want a field to
be created, you can pass the string into the field definitions with
add_field()
$this->dbforge->add_field("label varchar(100) NOT NULL DEFAULT
'default label'");
Note:
Passing raw strings as fields cannot be followed by add_key() calls on
those fields.
`$this->dbforge->add_field(
array(
'nombre' =>
array(
'type' => 'VARCHAR',
'constraint' => '150',
),
'paterno' =>
array(
'type' => 'VARCHAR',
'constraint' => '80',
),
'materno' =>
array(
'type' => 'VARCHAR',
'constraint' => '80',
),
'correo' =>
array(
'type' => 'varchar',
'constraint' => '150',
'unique'=> TRUE,
),
'username' =>
array(
'type' => 'varchar',
'constraint' => '80',
),
'genero' =>
array(
'type' => 'varchar',
'constraint' => '30',
),
'pass' =>
array(
'type' => 'varchar',
'constraint' => '255',
),
'direccion' =>
array(
'type' => 'varchar',
'constraint' => '200',
),
'telefono' =>
array(
'type' => 'varchar',
'constraint' => '30',
),
'celular' =>
array(
'type' => 'varchar',
'constraint' => '30',
),
'created_at datetime default current_timestamp',
'updated_at datetime default current_timestamp on update current_timestamp',
'status' =>
array(
'type' => 'tinyint',
'constraint' => '1',
),
)
);`
For Codeigniter 4 this is slightly different:
https://codeigniter.com/user_guide/dbmgmt/forge.html#raw-sql-strings-as-default-values
You would need something like this ...
'DateAdded' => array(
'type' => 'TIMESTAMP',
'default' => new RawSql('CURRENT_TIMESTAMP'),
),

Google charts line chart with non-uniform x-axis values

I need to make a google line chart where students answer up to five questions with a value from 1 to 100.
The line chart should have the answer on the y-axis and the time and date of the answer on the x-axis.
Students answer all questions at the same time.
There should be one line for each answer for each student.
Lines for the same question should have the same colour - ie. if there are three students there should be three lines of each colour, one for each student.
My data looks like this in PHP before it gets parsed into a json-string and loaded into Google Charts:
$testtable = array(
'cols' => array(
array('label' => 'Date', 'type' => 'datetime'),
array('label' => 'Student', 'type' => 'string', 'role' => 'tooltip'),
array('label' => 'Answer1', 'type' => 'number'),
array('label' => 'Answer2', 'type' => 'number'),
array('label' => 'Answer3', 'type' => 'number'),
array('label' => 'Answer4', 'type' => 'number'),
array('label' => 'Answer5', 'type' => 'number')
),
'rows' => array(
array('c' => array(
array('v' => 'Date(2014,3,4,17,3,17)'),
array('v' => 'elev1'),
array('v' => 15),
array('v' => 36),
array('v' => 87),
array('v' => 10),
array('v' => 22)
)),
array('c' => array(
array('v' => 'Date(2014,3,4,13,56,22)'),
array('v' => 'elev2'),
array('v' => 11),
array('v' => 66),
array('v' => 87),
array('v' => 23),
array('v' => 27)
)),
array('c' => array(
array('v' => 'Date(2014,3,5,10,27,31)'),
array('v' => 'elev1'),
array('v' => 43),
array('v' => 11),
array('v' => 33),
array('v' => 64),
array('v' => 88)
)),
array('c' => array(
array('v' => 'Date(2014,3,5,12,22,53)'),
array('v' => 'elev2'),
array('v' => 22),
array('v' => 34),
array('v' => 62),
array('v' => 32),
array('v' => 5)
)),
)
);
Here is what I have in mind:
http://s21.postimg.org/p146t1dqf/chart.png
Here is what my chart currently looks like:
http://s11.postimg.org/w6gvfa5n7/chart2.png
I'm pretty sure my data is structured wrong but I can't get my head around the right way to do it. I would be really happy if someone could help.
A LineChart requires one data series per line, so if you want one line per student per question, you need one data series (DataTable column) per student per question (so if you have 3 students and 5 questions, you need 15 data series). Use either the colors or series.<series index>.color options to color the lines.
'cols' => array(
array('label' => 'Date', 'type' => 'datetime'),
array('label' => 'Student1 Answer1', 'type' => 'number'),
array('label' => 'Student1 Answer2', 'type' => 'number'),
array('label' => 'Student1 Answer3', 'type' => 'number'),
array('label' => 'Student1 Answer4', 'type' => 'number'),
array('label' => 'Student1 Answer5', 'type' => 'number'),
array('label' => 'Student2 Answer1', 'type' => 'number'),
array('label' => 'Student2 Answer2', 'type' => 'number'),
array('label' => 'Student2 Answer3', 'type' => 'number'),
array('label' => 'Student2 Answer4', 'type' => 'number'),
array('label' => 'Student2 Answer5', 'type' => 'number'),
array('label' => 'Student3 Answer1', 'type' => 'number'),
array('label' => 'Student3 Answer2', 'type' => 'number'),
array('label' => 'Student3 Answer3', 'type' => 'number'),
array('label' => 'Student3 Answer4', 'type' => 'number'),
array('label' => 'Student3 Answer5', 'type' => 'number')
// etc...
)

Resources