mirror of
https://github.com/php/presentations.git
synced 2026-03-25 16:12:07 +01:00
42 lines
961 B
PHP
42 lines
961 B
PHP
<pre>
|
|
<?php
|
|
$db = new sqlite_db(dirname(__FILE__)."/db.sqlite");
|
|
// CREATE TABLE auth_tbl
|
|
// (login VARCHAR(32), passwd CHAR(32))
|
|
$res = $db->query("SELECT * FROM auth_tbl");
|
|
|
|
/* import result into my_class setting the row number
|
|
* and indicating that the data is from a database */
|
|
while (($obj = $res->fetch_object("my_class", array(TRUE)))) {
|
|
var_dump($obj);
|
|
}
|
|
|
|
class my_class
|
|
{
|
|
public $from_db, $row_num=0;
|
|
private $passwd, $crypt_key = "value";
|
|
|
|
/* constructor sets the row number
|
|
* and sets a flag indicating
|
|
* that the data originated from the database */
|
|
function __construct($fdb=FALSE)
|
|
{
|
|
static $counter;
|
|
$this->row_num = (int) $counter++;
|
|
$this->from_db = $fdb;
|
|
}
|
|
|
|
private function decode_passwd() { }
|
|
|
|
private function encode_passwd() { }
|
|
|
|
function change_password()
|
|
{
|
|
if (decode_passwd($this->passwd) == $_POST['passwd']) {
|
|
$new_pass = encode_passwd($_POST['passwd']);
|
|
/* update password query */
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
</pre>
|