./configure可加参数:
implemented configure options source file hsclient none (default) handlersocket.cc native --disable-handlersocket-hsclient handlersocet.c
Tips:If you get an error:
configure: error: Cant find hsclientheaders,please install libhsclient first,Or ./configuredisable-handlersocket-hsclient with-php-config=/usr/local/webserver/php5318/bin/php-config use native type.
[root@iredmail handlersocket]#make && make install
A successful install will have created handlersocket.so and put it into the PHP extensions directory. Youll need to and adjust php.ini and add an extension=handlersocket.so line before you can use the extension.
[root@iredmail handlersocket]# vi /usr/local/webserver/php5318/etc/php.ini extension=handlersocket.so
至此php扩展安装完成,放问php.info页面,我们可以看到已经成功加载了handlersocket扩展
/* * String $host:MySQL ip; * String $port:handlersocket插件的端口,它有两个端口可选:一个用于读、一个用于写 */ $hs = new HandlerSocket($host, $port); 打开一个数据表: /* * Int $index:这个数字相当于文件操作里的句柄,HandlerSocket的所有其他方法都会依据这个数字来操作由这个 openIndex打开的表, * String $dbname:库名 * String $table:表名 * String $key:表的“主键”(HandlerSocket::PRIMARY)或“索引名”作为搜索关键字段,这就是说表必须有主键或索引 * 个人理解:要被当做where条件的key字段,这样可以认为handlersocket只有一个where条件 * String $column:column1,column2 所打开表的字段(以逗号隔开),就是说$table表的其他字段不会作 */ $hs->openIndex($index, $dbname, $table, $key, $column); 查询: /* * Int $index: openIndex()所用的$index * String $operation:openIndex方法中指定的$key字段所用的操作符,目前支持=, >=, < =, >,and < ;可以理解为where条件 * Array $value * Int $number(默认是1):获取结果的最大条数;相当于SQL中limit的第二个参数 * Int $skip(默认是0):跳过去几条;相当于SQL中limit的第一个参数 */ $retval = $hs->executeSingle($index, $operation, $value, $number, $skip); 插入(注意:此处的openIndex要用$port_wr,即读写端口): /* * Int $index: openIndex()所用的$index * Array $arr:数字元素数与openIndex的$column相同 */ $retval = $hs->executeInsert($index, $arr); 删除(注意:此处的openIndex要用$port_wr,即读写端口): /* * Int $index: openIndex()所用的$index * String $operation:openIndex方法中指定的$key字段所用的操作符,目前支持=, >=, < =, >,and < ;可以理解为where条件 * Array $value * Int $number(默认是1):获取结果的最大条数;相当于SQL中limit的第二个参数 * Int $skip(默认是0):跳过去几条;相当于SQL中limit的第一个参数 */ $retval = $hs->executeDelete($index, $operation, $value, $number, $skip); 更新(注意:此处的openIndex要用$port_wr,即读写端口): /* * Int $index: openIndex()所用的$index * String $operation:openIndex方法中指定的$key字段所用的操作符,目前支持=, >=, < =, >,and < ;可以理解为where条件 * Array $value * Int $number(默认是1):获取结果的最大条数;相当于SQL中limit的第二个参数 * Int $skip(默认是0):跳过去几条;相当于SQL中limit的第一个参数 */ $retval = $hs->executeUpdate($index, $operation, $value, $number, $skip);
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-27115-4.html
有几条命