Просмотр поста

.
Koenig
(\/)____o_O____(\/)

Testing

/* 
-- 
-- Table structure for table `table` 
-- 

CREATE TABLE IF NOT EXISTS `table` ( 
  `id` int(11) NOT NULL AUTO_INCREMENT, 
  `name` text NOT NULL, 
  `pass` varchar(32) NOT NULL, 
  `time` int(11) NOT NULL, 
  `pid` int(11) NOT NULL, 
  PRIMARY KEY (`id`) 
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 
*/ 

$db_host = '127.0.0.1'; 
$db_user = 'root'; 
$db_pass = ''; 
$db_name = 'test'; 
$db_charset = 'utf-8'; 

$mysqli = new KoeMysql($db_host, $db_user, $db_pass, $db_name, $db_charset);

$sql = "insert into `table` (`name`, `pass`, `time`, `pid`) values (?, ?, ?, ?)";  
$array = array('test', 'qwerty', time(), 213); 
$res = $mysqli->sql($sql, $array);
echo '<pre>'; print_r($res);   

$sql = "select * from `table`"; 
$mysqli->set_where(array('pid' => '?', 'name' => '?')); 
$mysqli->set_limit(array(2, 2));
#$mysqli->set_limit(5);
$mysqli->set_sort(array('id' => 'd', 'time' => 'a'));
$placeholders = array(213, 'test');
$res = $mysqli->sql($sql, $placeholders); 
echo '<pre>'; print_r($res);   

$sql = "delete from `table` where `id` < ?";  
$placeholders = 100;
$res = $mysqli->sql($sql, $placeholders); 
echo '<pre>'; print_r($res); 

$sql = 'select count(id) from `table`';
$res = $mysqli->sql($sql);
echo '<pre>'; print_r($res);