No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

px_insert_record

(PECL paradox >= 1.4.0)

px_insert_recordInserts record into paradox database

Description

px_insert_record ( resource $pxdoc , array $data ) : int

Inserts a new record into the database. The record is not necessarily inserted at the end of the database, but may be inserted at any position depending on where the first free slot is found.

The record data is passed as an array of field values. The elements in the array must correspond to the fields in the database. If the array has less elements than fields in the database, the remaining fields will be set to null.

Most field values can be passed as its equivalent php type e.g. a long value is used for fields of type PX_FIELD_LONG, PX_FIELD_SHORT and PX_FIELD_AUTOINC, a double values is used for fields of type PX_FIELD_CURRENCY and PX_FIELD_NUMBER. Field values for blob and alpha fields are passed as strings.

Fields of type PX_FIELD_TIME and PX_FIELD_DATE both require a long value. In the first case this is the number of milliseconds since midnight. In the second case this is the number of days since 1.1.0000. Below there are two examples to convert the current date or timestamp into a value suitable for one of paradox's date/time fields.

Note:

This function is only available if pxlib >= 0.6.0 is used.

PHP: px_insert_record - Manual Home of Manuel PHP  Contents Haut

Parameters

pxdoc

Resource identifier of the paradox database as returned by px_new().

data

Associated or indexed array containing the field values as e.g. returned by px_retrieve_record().

PHP: px_insert_record - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns FALSE on failure or the record number in case of success.

PHP: px_insert_record - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 Set the date/time fields in a paradox database to the current date/time

<?php
$px 
px_new();
$fp fopen("test.db""w+");
px_create_fp($px$fp, array(array("timestamp""@"), array("time""T"), array("date""D")));

$curdate getdate();
$jd gregoriantojd($curdate["mon"], $curdate["mday"], $curdate["year"]);
$days $jd 1721425/* Number of days between 1.1.4714 b.c. and 1.1.0000 */
$secs $curdate["hours"]*3600 $curdate["minutes"]*60 $curdate["seconds"];
px_insert_record($px, array($days*86400000.0 $secs*1000.0$secs*1000.0$days));

$curtimestamp microtime(true);
$days = (int) ($curtimestamp/86400);
$secs $curtimestamp - ($days 86400.0);
$days += 2440588/* Number of days between 1.1.4714 b.c. and 1.1.1970 */
$days -= 1721425/* Number of days between 1.1.4714 b.c. and 1.1.0000 */
px_insert_record($px, array($days*86400000.0 $secs*1000.0$secs*1000.0$days));
for(
$i=0$i<2$i++) {
    
$rec px_retrieve_record($px$i);
    echo 
px_timestamp2string($px$rec["timestamp"], "n/d/Y H:i:s")."\n";
    echo 
px_date2string($px$rec["date"], "n/d/Y")."\n";
}
px_close($px);
px_delete($px);
?>

The above example will output:

2/21/2006 21:42:30
2/21/2006
2/21/2006 20:42:30
2/21/2006

The Julian day count as passed to jdtogregorian() has a different base of 1.1.4714 b.c. and must therefore be calculated by adding 1721425 to the day count used in the paradox file. Turning the day count into a timestamp is easily done by multiplying with 86400000.0 to obtain milli seconds.

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.px-insert-record.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut