Notatki w języku programowania PHP

SET Id autoincrement Mysql and MsSql

Mysql

ALTER TABLE `Table` AUTO_INCREMENT=18;

Mssql

DBCC CHECKIDENT ('table', RESEED, 71);

Kategoria: 

calendar

SET @start_date = CAST('2018-02-20 12:30:01' AS DATETIME);
SET @end_date = CAST('2018-02-20 14:29:59' AS DATETIME);
 
 
 
SELECT * FROM table
WHERE 
 
  (date_from > @start_date AND date_from < @end_date)
   OR 
  (date_to > @start_date AND date_from < @end_date)
  OR  
  (date_to > @start_date AND date_to < @end_date)
 
 
Kategoria: 

Find fields on all tables

SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('columnA','ColumnB')
AND TABLE_SCHEMA='YourDatabase';

Kategoria: 

mysql to csv

 SELECT * FROM plugin_objects  INTO OUTFILE '/tmp/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

OR

CREATE TABLE () (SELECT data FROM other_table ) ENGINE=CSV  ;

When you create a CSV table, the server creates a table format file in the database directory. The file begins with the table name and has an .frm extension. The storage engine also creates a data file. Its name begins with the table name and has a .CSV extension. The data file is a plain text file. When you store data into the table, the storage engine saves it into the data file in comma-separated values format.
Kategoria: 

timeout file_get_contents

The default timeout is defined by default_socket_timeout ini-setting, which is 60 seconds. You can also change it on the fly:

ini_set('default_socket_timeout', 900); // 900 Seconds = 15 Minutes
Another way, to set a timeout, would be to use stream_context_create to set the timeout as HTTP context options of the HTTP stream wrapper in use:
 
$ctx = stream_context_create(array('http'=>
    array(
        'timeout' => 1200,  //1200 Seconds is 20 Minutes
    )
));
 
echo file_get_contents('http://example.com/', false, $ctx);

RabbitMQ answer by Consumer

$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
$msg->delivery_info['channel']->basic_nack($msg->delivery_info['delivery_tag'], false, true);
$msg->delivery_info['channel']->basic_cancel($msg->delivery_info['consumer_tag']);

Usefull Links

A clean and simple dependency injection framework for PHP 5.4 inspired by C#'s Ninject
https://github.com/TimeToogo/Putty

-------------
Yet Another LINQ to Objects for PHP
https://github.com/Athari/YaLinqo

Strony

Subskrybuj Notatki w języku programowania PHP