Error: Table “user” does not have a primary key. Solution: The crud command requires primary key to be defined in your tables. If you are working with legacy tables and can’t specify primary key, you can declare it in primaryKey() method of your model class. override method primaryKey in protected/models/User.php [php] public function primaryKey() { …
Category: Windows
Microsoft Windows operating system.
Permanent link to this article: https://blog.openshell.in/2012/04/yii-primary-key-error/
Apr 15
APC extension Enable in apache
To enable APC extension on Ubuntu, Use the following command sudo apt-get install php-apc To enalbe APC extension on Windows, 1) Go to http://downloads.php.net/pierre/ 2) Download php_apc-.zip 3) Copy php_apc.dll to /ext folder 4) In your php.ini, make sure you have: extension=php_apc.dll 5) Restart your server.
Permanent link to this article: https://blog.openshell.in/2012/04/apc-extension-enable-in-apache/
Apr 03
Enable Sqlite in PHP on Apache
To enable SQLite on Windows/Apache/PHP setup, Uncomment the following lines in the php.ini file and restart Apache: [code] extension=php_pdo.dll extension=php_pdo_sqlite.dll [/code] To enable SQLite on Ubuntu, Use the following command [code] sudo apt-get install sqlite php5-sqlite sudo apt-get install php-pear php-apc php5-curl [/code]
Permanent link to this article: https://blog.openshell.in/2012/04/enable-sqlite-in-php-on-apache/
Oct 03
session-start – headers already sent
This happens when you try to start session more than once. [php] The solution for above problem is 1) in php.ini file set session.autostart to 0 session.auto_start = 0 2) Placing a .htaccess file in the root of your web directory with the following value: php_flag session.auto_start 0 3) In your code use this line …
Permanent link to this article: https://blog.openshell.in/2011/10/1263/
Sep 23
PHP characters limitation
Characters limitation will helps to display limited number of characters to display. [php] function limit_characters( $str, $n ) { if ( strlen ( $str ) <= $n ) { return $str; } else { return substr ( $str, 0, $n ) . ‘…’; } } [/php]
Permanent link to this article: https://blog.openshell.in/2011/09/php-characters-limitation/
Sep 23
Resize image in specified height & width while upload
Resizing images in specified height & width while uploading files to the server. [php] /* Create a thumbnail of $srcFile and save it to $destFile. The thumbnail will be $width pixels. */ function createThumbnail($srcFile, $destFile, $new_w, $new_h, $quality = 75) { $thumbnail = ”; if (file_exists($srcFile) && isset($destFile)) { $size = getimagesize($srcFile); $old_x = $size[0]; …
Permanent link to this article: https://blog.openshell.in/2011/09/resize-image-in-specified-height-width-while-upload/
Sep 20
PHP Automatic Session Logout
Automatic logout script if users have inactive more than 15 minutes [php] <?php session_start(); $inactive = 900; // Set timeout period in seconds if (isset($_SESSION[‘timeout’])) { $session_life = time() – $_SESSION[‘timeout’]; if ($session_life > $inactive) { session_destroy(); header("Location: logoutpage.php"); } } $_SESSION[‘timeout’] = time(); ?> [/php]
Permanent link to this article: https://blog.openshell.in/2011/09/php-automatic-session-logout/
Sep 19
PHP MYSQL ORDER BY Multiple Columns
If you want to Order 2 or more columns in SQL Query. When ordering by more than one column, the second column is only used if the values are identical with the onces in the first column. Example [sql] ‘Order by Column ORDER BY COLUMN1, COLUMN2 [/sql] Order 2 or more columns with different orders …
Permanent link to this article: https://blog.openshell.in/2011/09/php-mysql-order-by-multiple-columns/
Jun 09
Guide to MySQL database Engine.
A MySQL database gives you a choice of database engines and an easy way to switch them. Default MySQL Engine would be enough for most of your application but in certain circumstances where the other available engines may be better suited to the task at hand. Choose your engine The number of database engines available …
Permanent link to this article: https://blog.openshell.in/2011/06/guide-to-mysql-database-engine/
Jan 12
Reset Forgotten MySQL Root Password
Reset MySQL Root Password in Linux: You can reset forgotten MySQL database server password with following five easy steps in ubuntu. Step 1: Stop the MySQL server process. /etc/init.d/mysql stop Step 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password. mysqld_safe –skip-grant-tables Step 3: Connect …
Permanent link to this article: https://blog.openshell.in/2011/01/reset-forgotten-mysql-root-password/