This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Pads from left given subject with specified character. | |
* @param {string|number} number number or string to pad | |
* @param {number} width width of a subject | |
* @param {string|number} char character to pad | |
* @returns {string} padded subject | |
*/ | |
function pad( number, width, char ) | |
{ | |
char = char || '0'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$phpExcelPath = Yii::getPathOfAlias( 'ext' ); | |
spl_autoload_unregister( array( 'YiiBase', 'autoload' ) ); | |
$p = $phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php'; | |
include( $p ); | |
$objPhpExcel = new PHPExcel(); | |
$worksheet = $objPhpExcel->getSheet()->setTitle( "Данные из 1С" ); | |
$worksheet->setCellValueByColumnAndRow( 0, 1, 'Some value' ); | |
PHPExcel_IOFactory::createWriter( $objPhpExcel, 'Excel2007' )->save( $file_name ); | |
spl_autoload_register( array( 'YiiBase', 'autoload' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file_name = 'myfolder/myfile.log'; | |
$info = pathinfo( $file_name ); | |
$zip = new ZipArchive(); | |
$zip_file_name = $info[ 'dirname' ] . DIRECTORY_SEPARATOR . $info[ 'filename' ] . '.zip'; | |
$zip_local_name = $info[ 'basename' ]; // file name in archive without directory | |
if ( true !== $zip->open( $zip_file_name, ZipArchive::CREATE ) ) | |
die( "Compressing failed!" ); | |
$zip->addFile( $file_name, $zip_local_name ); | |
$zip->close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PHPExcel is extracted into protected/extensions/ folder | |
// protected/extensions/PHPExcel.php, protected/extensions/PHPExcel/ | |
class MyExcel | |
{ | |
private static $objPhpExcel; | |
public static function genFile( $file_name = 'data.xlsx' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get data from db: | |
$cmd = Yii::app()->db->createCommand( "SELECT name, sex, age, position FROM people" ); | |
// get reader object: | |
$dataReader = $cmd->query(); | |
// read records line by line: | |
while ( ( $rec = $dataReader->read() ) !== false ) | |
printf( "Name: %s, Sex: %s, Age: %d, Position: %s", $rec[ 'name' ], $rec[ 'sex' ], $rec[ 'age' ], $rec[ 'position' ] ); | |
// or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mklink C:\Windows\php.ini C:\OpenServer\userdata\temp\config\php.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd C:\OpenServer\domains | |
mkdir lara.loc | |
composer create-project laravel/laravel lara.loc --prefer-dist | |
# after successfull installing try to open http://lara.loc/public/ on browser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in config/main.php | |
array( | |
'components'=>array( | |
'format' => array( | |
'datetimeFormat' => 'd.m.Y H:i:s', | |
'dateFormat' => 'd.m.Y', | |
), | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in .htaccess | |
Options +FollowSymLinks | |
IndexIgnore */* | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . index.php | |
<?php | |
// in config/main.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @var SiteController $this | |
* @var CClientScript $cs | |
* @var CAssetManager $am | |
*/ | |
$cs = Yii::app()->clientScript; | |
$am = Yii::app()->assetManager; | |
$assetsDir = Yii::app()->basePath . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR; | |
$cs->registerCoreScript( "jquery" ); |
OlderNewer