Codeigniter add_column not working as expected - php

I'm trying to add some extra columns to an existing table with the codeigniter dbforge way.
I'm doing everything like this here. dbforge,add_column.
It wasn't working with the migrations, but after i tried to put the exact same code into some of my controllers with profiler turned on.
After this, i saw this info on the queries part. (Attaching an image)
I saw something like that in the buglist, but there it is fixed. So after this i tried to download a git version from codeigniter, but there is the exact same problem.
The code i'm trying to run is this:
$fields = array(
'preferences' => array('type' => 'TEXT')
);
$this->dbforge->add_column('users', $fields);
I'm sure that is something with the file at system/database/DB_forge.php file, but i wasn't able to resolve it.
Could someone point me in the good direction? Is something i'm doing wrong? Is something missing?
Thanks in advance for your kind help of all.

Related

Silverstripe 3.4 Module to extend image is not creating the database columns

i am sure i am missing something obvious, but this is my first attempt to actually create my own module, and the documentation just doesn't seem to be doing any good for me.
The issue is that the dependency on this new field i added seems to be working, as i get the SQL error saying that it can't find the field in the Image Table, but /dev/build is not creating the new column. I even tried manually adding the column, and then everything seems to work fine -- but this will not help for installing it onto my colleague's computers, or onto any other site.
Here are the basic files as they stand (some of the names have been changed a little, but the gist is still the same):
/tinyimage-uploads/_config.php
<?php
Object::add_extension('Image', 'TinyImageExtension');
/tinyimage-uploads/code/TinyImageExtension.php
<?php
class TinyImageExtension extends DataExtension {
private static $db = array(
'Compressed' => 'Boolean'
);
}
There are tons of methods i need to put into this, specifically onAfterUpload() -- but i can't even get this one field created. I have tried basing this off of Focuspoint Link to Github -- as this is also installed on the site, but i am just having no luck with this. All the documentation tells me that this should be enough, and some tells me that no static methods are allowed in DataExtension... but that seems to work fine in many of the other modules we have installed.
Please help, this is driving me crazy and i don't know if it just means there is something wrong with my Apache or if i am just missing some basic files for modules and just not having any luck finding the right documentation to get me started.
You can try removing/deleting the line
Object::add_extension('Image', 'TinyImageExtension');
from /tinyimage-uploads/_config.php and leave it as an empty PHP file and instead do this.
Create a new yml file at
tinyimage-uploads/_config/_config.yml and add your image extension to it like this
---
Name: tinyimage-uploads
After:
- 'framework/*'
- 'cms/*'
---
#Custom Image Extension
Image:
extensions:
- TinyImageExtension
Finally run dev/build and confirm that the Compressed Boolean data column has been created in your Image database table.
Hope this helps.

Laravel Elixir watch not working properly

So when I create a new Laravel project, gulp watch worked very perfectly. Now I'm working on PyroCMS project which is also used Laravel and the gulp watch kinda fails. I don't know why.
It seems to have a problem with watching multiple sass files at the same time. It does not watch at all. However, with one sass file, it works perfectly.
Here is my code:
var sassPath = './addons/dscms/anomaly/generali-theme/resources/sass/',
cssPath = './addons/dscms/anomaly/generali-theme/resources/css/',
jsPath = './addons/dscms/anomaly/generali-theme/resources/js/',
jsCopyPath = './addons/dscms/anomaly/generali-theme/resources/js/my-js/';
elixir(mix => {
mix
.sass([
''+sassPath+'main-style.sass',
''+sassPath+'section1.sass',
''+sassPath+'section2.sass'
], ''+cssPath+'main.css')
.scripts([
''+jsPath+'main.js',
''+jsPath+'main-2.js',
''+jsPath+'main-3.js'
],''+jsCopyPath+'main.js');
});
It also work with multiple js files but not sass files. Please help me with this one. Thank you very much!
I'm sorry for that. That was completely my fault :) The syntax was a little bit wrong there. The correct code is like this
mix
.sass(''+sassPath+'*.*', ''+cssPath+'main.css')
and I tested it. It watched multiple files and concatenated into one file. Worked perfectly!

Has anyone used the tel: protocol in the Yii Framework?

The following code gets stripped down at runtime:
$PhoneHomeLink=CHtml::link($this->phone_home,'tel:'.$this->phone_home);
Assuming the home phone number is 999-555-1212 the output is displaying:
<a>999-555-1212</a>
What happened to the:
999-555-1212
Hi I thought this would be easy but I guess it's more work than I planned. Does anyone have any ideas?
OK for anyone interested, I tested the function in a few different places and it worked so I figured out it was implementation on my end.
I wanted to create tel: links inside CGridview with the following code:
'home'=>array('type'=>'html','name'=>'home_phone','value'=>'CHtml::link($data->phoneHome,"tel:".$data->phoneHome)','htmlOptions'=>array('width'=>'120')),
and after scratching my head and digging and digging I found out the alternate 'type' called raw which worked magic in this situation. I just needed one item in that line changed as shown here:
'home'=>array('type'=>'raw','name'=>'home_phone','value'=>'CHtml::link($data->phoneHome,"tel:".$data->phoneHome)','htmlOptions'=>array('width'=>'120')),
For Yii 2.x CHtml() is deprecated.
Use Html(). Here what I use in a DetailView::widget() for a phone number to be called.
['attribute' => 'CW_phone',
'format' => 'raw',
'value' => Html::a($model->CW_phone,"tel:".$model->CW_phone),
],

FuelPHP oil refine migrate not working

I'm stuck at the beginning of a new site.
It's my first time, trying to use oil for generation / migration.
I successfully create a model using oil and now I want to migrate it, but
php oil refine migrate
gives me an error:
Error - invalid data source name in COREPATH/classes/database/pdo/connection.php on line 94
With a little bit of research I found out, that at least I'm not completely alone with this error, though none of the discussions I saw has been solved so far.
My db-configuration is all fine and regarding some hints I even overwrote php-cli's php.ini with the one, apache is using.
But no luck at all.
Anybody out there, who knows a solution? Any help appreciated!!!
EDIT:
I wanted to go on developing even without oil but now found that I can't even run migration from php. It's the same error message which doesn't help at all.
Please guys, anybody just has to know a solution...
have you set the database conneection in the file: fuel/app/config/development/db.php? and is in the correct form:
return array(
'default' => array(
'connection' => array(
'dsn' => 'mysql:host=localhost;dbname=fuel_intro',
'username' => 'root',
'password' => '',
),
),
);
By the error it sounds like you may have the wrong sytax in your config.
I hope this is helpful, if not please post your db config file source.

PHP 'QUERY_STRING' not returning anything

I'm using the following in my php code:
$file="query.txt";
$f=fopen($file,'a');
fwrite($f,"Query String:".$_SERVER['QUERY_STRING']."\n");
fclose($f);
It never returns anything. I'm simply trying to record the queried url when someone visits (i.e. http://example.com/index.php?q=string. Other $_SERVER fields seem to work just fine, it only seems to be the query string that doesn't work. Maybe there's something I need to setup in my .htaccess?
I'm hoping someone has an answer to how to get this to information to show.
This solved the problem:
$_SERVER['REDIRECT_QUERY_STRING']
solution from https://stackoverflow.com/a/11618256/1125006

Categories