How to find the value of a single field in cakePHP

Use the model method field if no matching data is found it returns false. Example $this->Model->id = 10; $this->Model->field('name'); The example above displays the value of the name field in the database where the idis equal to 10 Read more here

March 22, 2018 · 1 min · 41 words · icarnaghan

How to fix itunes could not connect to this phone. an unknown error occurred (0xE800000A)

Error: itunes could not connect to this phone. an unknown error occurred (0xE800000A) when connecting your iPhone 4 to iTunes on Windows 7? Solution: On Windows 7 locate c:\Program Data\Apple\Lockdown There should be two files in the folder, delete these two files, reconnect your iPhone to iTunes and it will appear again without any errors

March 22, 2018 · 1 min · 55 words · icarnaghan

How to force a CSV file to download when clicking on a download link using PHP

Example: We have a CSV file called example.csv we want users to download to use as a template. Now some browsers will display the contents of the file instead of asking users to download the file. What we want to do is to force the downloadinstead of displaying the contents in the browser. Create a new PHP file called ‘download.php’ Open the file for editing Copy the code below into the ‘download.php’ file {codecitation style=“brush: PHP;”} header(‘Content-Type: application/csv’); //Outputting the file as a csv file header(‘Content-Disposition: attachment; filename=example.csv’); //Defining the name of the file and suggesting the browser to offer a ‘Save to disk ’ option header(‘Pragma: no-cache’); ...

March 22, 2018 · 1 min · 174 words · icarnaghan

How to force your website to use https instead of http via the .htaccess file

Did you recently install a SSL Certificate for your domain and need to force access to your website via https instead of http? This can be done using the mod_rewrite Module with the Apache HTTP Server. Add the following code to your .htaccess file, save and refresh your website. RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] This permanently redirect all http request to https

March 22, 2018 · 1 min · 66 words · icarnaghan

How to get current controller name and action name in Yii

$controller=Yii::app()->controller; $action=$controller->action; //Getting the current action echo $action->id; //Getting the current controller $controller->uniqueID

March 22, 2018 · 1 min · 13 words · icarnaghan

How to get the Attribute Label of a attribute in a Model using Yii Framework

Use the getAttributeLabel() method (available since v1.1.4) Code Example: Products::model()->getAttributeLabel('brand_id') The above example gets the attribute label for the brand_id attribute in the model Products.

March 22, 2018 · 1 min · 25 words · icarnaghan

How to get the Base URL using the Yii Framework 1.1.x

To get the Base URL within the Yii Framework use the following code <?php echo Yii::app()->request->baseUrl; ?> This can be called from anywhere within your Yii Framework application

March 22, 2018 · 1 min · 28 words · icarnaghan

How to get the current UNIX timestamp using PHP

UNIX TIMESTAMP: Is the time measured in seconds since the start of the Unix epoch “1 January 1970” Use the PHP time function as per example below echo time(); //Will print out the current timestamp //OUTPUT: 1285365600 To read more about the time function click here

March 22, 2018 · 1 min · 46 words · icarnaghan

How to get the first element of an array using PHP

If you have the array $array = array('a','b','c','d'); you will need to get the value a from the array Answer: Use the array_shift function available in PHP 4 and 5 which shifts an element off the beginning of an array. See example below $array = array('a','b','c','d'); $first_element = array_shift($array); echo $first_element; The above code will output a

March 22, 2018 · 1 min · 57 words · icarnaghan

How to get the last character in a string using PHP

This can be done by using the substr which will return a part of a string. The sample code below will return the letter f $lastChar= substr("abcdef", -1); The -1 is negative, the returned string will start at the last character from the end of the string.

March 22, 2018 · 1 min · 47 words · icarnaghan