Skip to content
Advertisement

Tag: yii

Yii2: Controller action parameters with a dash?

If I have a URL like https://example.com/controller/action?customer-id=7414 how do I get customer-id in my action parameters? Since a dash is not allowed in variables names I cannot do the following! Documentation is usually excellent but on this exact point it’s just silent. How do I solve this? Answer When yiiwebController calls action it only binds parameters which names match exactly.

Yiimp: CDbException: CDbConnection failed to open the DB connection. error when hasGetInfo is set to false

I’m getting the CDbConnection failed to open the DB connection error. The thing is, my database connection seems to be okay, as evident from the fact that the YIIMP logs display the retrieved values that I print out (see the text in the yiimp-logs/debug.log). I haven’t modified the YIIMP source codes besides adding the debuglog lines. I’m running the server

How to change dateformat on Yii platform?

I am new to the Yii platform, and I am wondering how to change the dateformat. It’s currently in the American date format that is YYYY-MM-DD. I want it to be DD-MM-YYYY. Is there any way to this? Answer config file add in ‘components’ => [] You can add it and edit it to your style.

copy() fail to copy image from url to directory

I’m trying to copy an image from a URL to my server, but it doesn’t save. Below is my code The image URL in $url, doesn’t have a file extension, but the image is a .jpeg i tried both copy() and move_uploaded_file() but failed. when i use copy() i get this error I also tried with directory 2018/jeep/grand-cherokee exist and

Yii2 Migration move data to other table

I have table: and I have created table I want to move some data(date_used & used_by_user_id) from table ticket to other table used with migration yii2 in the query. But I don’t know how to do it without ActiveRecord & array. Answer Only sql. Yii-migration not supported select in the insert into

Set reason for thrown bad request in Yii 2

I’m writing an API and I have to throw HTTP 400 bad request like below and it works fine meaning that it displays the default HTTP 400 page (I have no views defined because I’m building an API) What I would like to achieve is to give some reason for the bad request error thrown so that who is using

Advertisement