本次使用的demo是MySQL的示例数据库employees,点击下载地址,注意在导入的时候,在employees.sql文件中,将source改成你当前的目录。

PHP中的demo代码可以在ideone下载到。

这里使用的是mysqli的方式,其他还有mysql和pdo方式,官方有篇比较的3者区别的文章《Overview》。

一、连接数据库

1.1、连接

mysqli_connect

打开一个到 MySQL 服务器的连接。有面向对象风格和过程化风格。

$link = mysqli_connect("localhost", "root", "123456", "employees");//面向过程
$link = new mysqli("localhost", "root", "123456", "employees");//面向对象

如果成功则返回一个 MySQL 连接对象, 或者在失败时返回 FALSE。

1.2、设置编码

set_charsetquery。query在下面就会有讲到,这里的话其实就是执行一条语句“SET NAMES utf8”。

设置在数据库间传输字符时所用的默认字符编码。

$link->query("SET NAMES utf8");//执行语句

mysqli_set_charset($link, 'utf8');//面向过程
$link->set_charset('utf8');//面向对象

成功时返回 TRUE, 或者在失败时返回 FALSE。

二、查询

2.1、对数据库执行一次查询

mysqli_queryquery。返回的信息中并没有记录信息,需要再使用方法获取。

$sql = 'select * from employees limit 10';
$result = mysqli_query($link, $sql);//面向过程
$result = $link->query($sql);//面向对象

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKwAAAB6CAIAAACtNC+9AAAFfklEQVR4nO2cW3qlIBCE3f+WsqnsoOclk++E7i4KRAStejJIX4AfUDwzx/f399fXl0kv1jEHguO/wltXRyczIW2zP33lnvzu0CQIfoIt0y9FJkxiv3UKDi5NbI4EQfAnX//JEBx/VRRm136p9IVhlEqKfwMB28Op8OAzCeuHOVTNcbuqXURmcoXSleA3M0vAL27hav4aF/o6VZ9kbsyf1SSrLQW3cG6Th/8naBMEWUlT+8NAlSzhjM8yWQoCP++ZQHM0AILPcv4aF+I62KR1hJgcBq4EOOIeEBgxxjMhmLMd4EB8ktXcFoKgWLXwMuuXZV8eLuBhYZBiVAeUZIUgE99GkEk1N99LOOFqlKvV/IrYmt/k9qyjjRreAEF1yp40OZz4QOtox+SnHhZJa0oQSIJAIiHYa4eTWlWHQAQ8XoJAqk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st7JZqQ3CfeC0HPHSDQREOYG2niRdGIYa6NUz2u/bwfhOiGd0X4QSMMlCCRBID3pwVCPCN162gek+S91D9CK/4Xd2BCjrI6bTnImSBCwhoJgULDoLO93gQ2vsyOBbGXGw4PPGKq2ZM3ttNZKEHa0LwTjcXJ4gLkgGBSMmLh4mMN1Ajs8k152VxCcCDYOAj5EcRfsL3zyguBEMG4Lr+4Rw7cDxkoQDAqWDDkeyIEPhnxWWc0w6O5a7sSwe1yfOkITtNC3g+xBT0N7tRaCQLpLgkASBBKAQNvwe4RWAnHwEgkCqfZMIA7eIEEgCQJJEEgmCCTT24FkgkAynRhKpm8HkgkCyQSBZIJAMkEgmSCQzOwfgyoLZ+dxz04AAAAASUVORK5CYII=" alt="" />

失败时返回 FALSE,成功执行SELECT, SHOW, DESCRIBE或 EXPLAIN查询会返回一个mysqli_result 对象,其他查询则返回TRUE。

接下来的2和3就是根据mysqli_result对象来的。

还有就是下面的所有方法都有面向过程和面向对象的方式,为了节省篇幅,下面例子都是面向对象的方式。

2.2、查询记录获取

fetch_all、fetch_array、fetch_assoc与fetch_row,返回的是array。

fetch_fields、fetch_field、fetch_object与fetch_field_direct,返回是stdClass Object。

data_seek

重置指针到起始,当做fetch_fields、fetch_assoc等读取数据的时候,指针会变化。

fetch_all

返回记录数组,这个方法有可以传递一个参数resulttype,三个常量MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH。默认是MYSQLI_NUM。

$data = $result->fetch_all(MYSQLI_ASSOC);

获取所有结果行并返回结果集作为关联数组,数字数组,或两者兼而有之。

下面的第一张返回结果图,引用的参数是MYSQLI_ASSOC,第二张引用的参数是MYSQLI_NUM。其实就是key的不同。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQ4AAACsCAIAAAAFcNWjAAAI90lEQVR4nO2cXZLjIAwGff8r7aX2Bt6Hoaa8SEif5V+S7oetBCOQMY2Js5Pl79+/f/78WQEgZEEVAIVElWVZ7swG4LWgCoBEpMqPJ9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5/SDdoJTkeZr5klMHaqaZJ0tot2DyK3Z00V6f+V2ZK4nRmGuq0ZYoHxoJxQvRvjVqqX/brkJtHs5z7xV0A4CQDsIAO0gALQT3vdI8VjQTlD3vdSdiyGVqzFjNziMLZXOmjtBO8HQa8hOhNO8/oaK7aLdg7CnV09YTxP9lfvrRLsHoV6M2km2OFEW09Ow3Fx/Kfe36FxO3AfaCRNGO09DqUxpYlpo9LCo3R0zuw3aCXO0axjtdu0NbJqYG2LR7tEM0c6eZIsXVQ1Ibauau9Hu0TgvRvOF8STaijDJvhDnQrvtwjidyz0TqGu+S7BRcpTnRuJc0zeBdkLx1E++Ni8G7SAAtIMA0A4CQDsIAO0EHimmgXZCzqeQDZR3K452gnqNR+3bORMv2rU19HzQTlD3adPyHhuKuWj3OXJ6VWm3JditqOk72n2HIdo1NJR+pI6ybwLthMs7SvU4/bGnldynaPchUr3UibJnkvWs7Xa0+xS3bqA4E9HucxgbKMac21O52tZ+0u6t5qGdkHv29AeAE7SDANAOAkA7CADtIAC0E3ikmAbaCcZ28ZwNlGJP2grTytWY5tyGuxHtBOe28K3bxXuyXace24X2gO2v2ZPrSVSqQruDu7Xz5zZo11Nzc277HYh2B8Yka4SlleRmZ096GmMfX9TxzJLpsTM3rach8f90tDsw9ModD2nIDjjLcSk/l1yO98wNUKw5zTLunLRRJ2gnGCduoHa1o92evKtV++PsoTHaObs35G5EO2HIaGcPFc5rkwsL1855ioqgnXD3JOtPrJJjmnbGbGsnKlWh3YF6WptHrGLlRqS62Cr2LRdZTHTmqqO4s9FrVWh3UDyDbacYUtAOAkA7CADtIAC0gwBW1Y51/dKsqt2OeSuDdhDAwtrtmLcsaAcBoB0EgHYQANpBAAtrh3PrgnYQwKra4dzSrKodLA3aQQBoBwGgHQSAdhAA2kEAaAcBoB0EgHYQwH+hPvnxJhJO3gAAAABJRU5ErkJggg==" alt="" />

fetch_array

返回一条记录数组,或没有记录返回NULL。与fetch_all一样,也有个参数resulttype,三个常量供选择。默认是MYSQ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nVXAT+xj/eQ/MoLDyp3I4mIcPlstMkwEc4uzGthoBzr1o0Zn/tRIPzXST430U+Pp1/vX6wlGv3rAu5F+auK1Xz3gxUg/NdJPjfRTI/3U6M2fGumnRqd+1OjMnxrpp0b6qfkD3Ye8gszamOMAAAAASUVORK5CYII=" alt="" />

fetch_assoc

没有resulttype参数,返回的是一条关联数组,或者没记录返回NULL。如果数组中包含相同的键名,那么将取最后一列。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAACGCAIAAADBzYiwAAAHWUlEQVR4nO2dW5rkJgyFa/9b6k1lB85DehwGSUdCNha4zv8wn5tCF+BYtHFX8vnnDz8/PwchFXyoQlJOSIWfz+fJnMi3QRWSenwV/idBCpHMI6PCz+dzNloXbc/2I3lNSLIWSg2pLcAJJUhOQirECrNaVHPu70TiqNCqXkEVduI7qEKiMVGFcVvy5SAVus8WbYWzNm618/Rhka14+t0JJUgkz6mQpzPEgu+RST1UIamHKiT1DKiQv9KRSURVSAmSeVCFpB7+fSGphyok9VCFpB6qkNRDFZJ6+IxM6qEKST18d0Lq4XtkUg9VSOqhCkk9VCGpp0CFK/zp/wo5kJMaFT4TyCWRyZCJ+u3YTv34u4sXs90FqnCWFZaR/K8DqN+U7b5rm8h2C6jCiYY3qjAedEeWUGG7AVlfpJeNqufWieofZ6Jmld4fqcIg9Sq01qZbp+B6dNrFhhfX1TWnCoMsocKu3lxUYXc9SYWshTeyhArVDuUqBDtyUBBUYZC1VLhFLYxbUYVB6lV4aE8nR7NO7UVXk4Af1dbNJJF8MBmr8Uq317DNu5N7F+Ddi7ode7xHBrWBenoBe6iQvBuqkNRDFZJ6tnk6WZn3jehhik9qwOLljlESj953qWfquY/aWT2ZSp/y3GgYt/3tXH5eeEUE6sJcd5JzmBtIdJ20Ze6uVVeym5uG9DZkGLf9vw9VWKvCuGFOhcFAVGG/iYAK3/VXN5G2M04DxwUhVP+umi2Hrq3axxq1lZubnvQWSc/tto0K3euzxV28TkaRHPCkB7P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BJldGoX5KFQapV+Gh7bPYKlgLsUPQ3mal7siusKjCIepVqIpSXidUOKkWRqyowiGWUKFabLotVf54iHKFbbHcc8lbfToVUoiY+ncnQzvdpBxILUu8R6YmvpwlVEi+HKqQ1EMVknrqn072Yuvkl2WJ//eT2+2uuHf5nHfQaHVW1R9vlM6to6uc7cWbc4nzwmfiurHimeSnO2bYrah6jRtBoCHPEduIIYYqzGRyJee4EPG1bLziOW17y/KtosL27gc1P9JTjSh7ti2fv1FtwRBAODW9yMq5KjyEDuT8xD0HbaWfhKHiagUVgvvb6ul2xt2C9SARLkjkzlEztG6kQ5tJ9X5wPUsrMDPW8g2xhArda8sQTFPEp1xFaauGuKjCiLma6vH38nedb78thzxEDE2HW6twNBxeADdiMDQuJIm01fYqFQaXb4iXqPCWSccR75nuwd+6QIYlKoxP0RBLnBe2c2EVErW0qMVGjYgddo2qrTWE3MCDCYMc1PbRCXEbLcNIenH47mSMrZNflle9R/4IqjMiIV6lQrIpVCGphyok9Tgq5K9W5AH8WkghktlQhaSe0O+FFCKZClVI6qEKST1UIamHKiT18BmZ1EMVknr47oTUw/fIpB6qkNTzLzDKL+omHQydAAAAAElFTkSuQmCC" alt="" />

fetch_row

同样没有resulttype参数,返回的是一条数字数组,或者没有记录返回NULL。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJwAAACICAIAAACdnRWXAAAFGUlEQVR4nO2aW5akIBBE3f+WelO1A+djzqmxySQyeSgSE/FFYz4oL6RCe3w+n8/n8/Pzc0osOgSVT4JKKEElVAz1OI4nBySNS1AJFUD9S1Rc91Iz1OM4vp21xtXyesm2pTvUs1ItErcHBBHRWxVDxcBqPa67ivkzQlBraysJtWB5CupTugtq3learirU8DXnuv5qVdo1vv03/fd69ERJRJ/RQ1C1jXlSOvsllKASSlAJlYWqx+FGSkEV0b0kqITS/1MJJaiEElRCCSqhBJVQevsllKASSidKhNLZL6EElVCCSihBJdTTUMPvWvThy7gWQLU9me/F+4LnjfEHkdisNfXd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fprm+HmrGrDs+MKvNoW8bd+Jik4+c8c04/gpCBjXv2wF1JHK3b8etWA+1Vm1wkFrdzrhbG9wuwGTqp20nfW2cHsflUMP2lETY4Hrri/5rT9E+K9MrjGy9wLy0SePf/oazX3tpEGrrSj3NmbA7nuQIwUpNDm9wrm+5UvE0z/7y6HG+CmryFqEIO0LNx09ahrf+MaigDmPHXy7Ly+/IaguDA0v3IReOrWYZOiZ93QqUTPoviE6U+KSzX0IJKqEElVCCSigEVW8rmypYqeK6owSVUPEzVVy3k6ASSlAJJaiEElRC6e2XUIJKKJ0oEUpnv4QSVEL9AatffIIyOKrYAAAAAElFTkSuQmCC" alt="" />

fetch_fields

用此方法获取表中所有的字段信息,包括字段名、字段长度、所属表等。

返回多个对象的数组,如果没有就返回FALSE。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPMAAAEVCAIAAAC6/kRDAAAOWElEQVR4nO2cW5ajOgwAs/8tzabuDrgf0cmh0cOywcQoVR99aLBkORTGgZl+/ffff//+/dsAavHCbCgJZkNNGma/Xq87qwG4CsyGmkRmv7VGbngifWa/Xq/PTm9j33J/SG8DzKN7ztZemnuCJGgNN9AwO7bW22OGs7aBO3HN9mbZpNkHoTfMhnuZYnY+FmASttnN73/7mdhbtJiNpw8IYNu2O99BojXcyR1m86QP7od/NwI1wWyoCWZDTVJms0SGx9E2G63hiWA21IR/nw01wWyoCWZDTTAbaoLZUBOejUBNMBtqwjtIqAn/bgRqgtlQE8yGmmA21ORWs5v/bYz/VwZXcbfZek/mj/WMJb+E+D/q33ApHvI3p4Z5lTyLb5p9+Z8lmRT4+YsUXvt5Ppl/0OLy7kpeD6XMHo5tmp1R/3K8jwuzMzzP7Jci7iWTwVsUBb3E44qzeXuaaYPAuFOvjPwYH8fzzB7oqNlpfHl0md3M/1GqWW1gdrNNV6fFnH5T0OxmuDm3BUl65+xPSJykN+2A2XqGTtZfgOeZ/VIEXSSLudbs5K3A29OVNvmRxn1h9unOFng2MrYaiSuctBq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NcFsqAlmQ00wG2ryPwTpRTXDab1PAAAAAElFTkSuQmCC" alt="" />

fetch_field

与上面的方法相对,只会获取某一个字段信息。配合field_seek,可以根据需要获得某个位置的字段信息。

返回一个对象的数组,如果没有就返回FALSE。

$result->field_seek(1);
$fields = $result->fetch_field();

注意上面的代码,返回的将是第二个字段的信息。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAL4AAADxCAIAAAD6GJpzAAAMsElEQVR4nO2bW7bcKgxEe/5TyqQyA+5HbhwfJBVCgBHt2h9ZbqwXuAw2Pvn8/v379+/fv379KoT08KF0SIyZ0vl8Pp/Pp/p5Nd6P13FP0Uy3upjvJiIdMOL3y6baL71aMvv0dFTbxRLpeLQ1nSpys5IpWd5MQzrWotNcm8x84lQzGmgEkWXBzqRW962+vxYkHeeiI0/5pYN9r2OQHUfGjjh+s/HluGYd2Wj9DMw6pdR3vJUUX7ZB6cgZxSoV1PAqXM86QCtlWDrWpeq9crNmnXABb2PJgjXiG16wVHsuWOtoSMd6KqwarQlf/Yl9mzaN/vQ4qpbqCIAUr+XVu8lUwAhvlI5zAiOYN0qHTIHSIUEoHRLEKx0+GZCKyJYgIYXSIWHa0qFuiAqlQ4JQOiQIpUOCUDokCN+wSBBKhwThbjIJwm9YJAilQ4JQOiQIpUOCPC2dpX/cyb8cfZIN0kmYwuOCRdmbNCDxbHcFpdPhNVi8/E85gxG6zk6H0ulwpHR+pNsonWsGtv7fXfUTm6kp1AKsgF2+oAzZLzWj2vdYXtwjT4oAm2cddSil8f0UMFN/DlZoncJJPZqWffcnbTY2Cx5nv3SsY0tVnvtsVnngbFM6zeDO64qTYv2BURono3SsA2vWwSnkWWtAm4ObSjpguDxhx0knHTA6lnSmzDoerzzSefuCJedbdTG6t6tmIEWgKmymzlWyTlCbWrxqDFLgRtXX08EuuJtMgvAbViLEVJv6HqB0SBBKhwShdEiQr3pMDpOzquR84efPMLHaPF5Al4GkAZWvuDEonX+Ea3OqJxZc9Y0JLnxWd6F0L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eYY0UNtxJaqvWrDlFfB1WuZk///+rI7VAbVGWY0m/3WmbpoFcM6ylI4jn0M66jzkj6aKpjklqDMTSO2Bs87UfD2zjuWFo1VxLP05E4UXrKYaKJ3OfO9YsDxelE5nPviYXK1Zqhn2KjfRVNGcLc2CA30ElmrSI+BusslBpW6B37BIEEqHBKF0SBBKhwRB0uETIgE0Zh2qh1hQOiRI+1mH6iEqlA4JQumQIJQOCULpkCB8wyJBKB0ShLvJJAi/YZEglA4JQumQIJTOe8HPss0/7/8PsE6oqf0vPPoAAAAASUVORK5CYII=" alt="" />

fetch_object

可以传入两个参数class_name和params,返回一个关联对象,如果没有数据返回NULL。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANYAAACHCAIAAADlUzArAAAHt0lEQVR4nO2dW5LsKAxEvf8t9aZ6B56fGzVuJKWEAAu78nxMuDB6AGlRhfvGHL+/v7+/vz8/PychFRyUIKllpgSP4ziOo/n4abxer+Mawg23OhkSISNBsHLX5Vf7L111GX16OKp2OkskGNHodBrPbiZTopBxHAlam6m755rxxC3XG2gEnmXCwaDW8K2xk0GQBIObqbwVlyC2/VyD6NgzNsT+3UYyhVAVlI3Wx0QVPM+2AllB8fIPSlBWOCtVkANJEPouCDR3DkvQWvJeBcyqgukESI4lG/GIbXojVvtzI94fR4LWt++m0drI1I/Y1u3jjKfHUO2pzgAIQQb56rcjVNIOfKMEgwWV3MM3SpBsBSVIiqEESTFRCfKbE1lE5miakIlQgqQYX4LUH1kKJUiKoQRJMZQgKYYSJMXwFzEphhIkxfDtCCmG74hJMZQgKYYSJMVQgqSYuyW4wx/N75AD+VAgwXsCuSQy6TKRncG/DMTdctk+BUpwiRXW0NH5L6bfXbMpwVWGEyUYD/pE6iV43XeOvzQdcDFonKj+cSZqVultkRIMUixBa2GaRQouRiNcbDi4qK45JRikXoJNpRmUYHO9SIKsghOpl6DaoVyCYCMOqoESDLKRBB9RBeNWlGCQHX+OnJdFul401Qj4UW3dTBLJB5OxGke6vYZn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WJAglMWqTdhENoaguqEEvwbD/7IsBpBUcFPv3SrhmgkKLuBIeQGHklYtuPcQIs6k9j2Nvh2pINHJ78t73lHrBY2sj/vkSB5KJQgKYYSJMV848+RHXIgH7Y4Fxx0uO6UJGGinoAk0vseHi/BtM91Vo0EE1G+CkpwviEl2EW9BOVJnvrxFCuqHgEGbdVMrKxytmpQIql/QWddNI1NB6sbtgWZ9ALMrxlSgi47SlCti40JUBuwBZmMjEK9SwkG2WUjBh3OHglGIuL2a1bqRuyqihLsYpcqqLYkqiBuxKEjRKwowS7qJaiWmWYnlR9PUaiwLdZ6LnmrTyNBqhBT/Haka4NblAOppf4dMQXx5dRLkHw5lCAphhIkxXzjH2uleXTy21L/f19yu82KO8vnugNFq7Mq/XijdG6dUuVsB5/M+nPBe+K6seKZ5Oc6Ztgsp3qNG0GgLs8R24ghhhLszmQk57gK8bVsHPGctp2yfFtI8Prcg1If6alGlD2vLcdfVFswBBBOTS+ybK4ETyECOT9xz0Fb6SdhqLgqlyB4sq2ebmfcLVgJEuGCRB4bNUPrKTq1mVQfBteztAIzYy1fF/USdK8tQzBHEZ9yCaWtGmJQghFzNdXz79o3nac/k10eIoamw+dKsDccnn03YjA0LiGJtNX2KgkGl6+LN0hwyozjiHPmuvObFsiwRILxKeqi/lzwOhFWCVGLilpm1IjYYdOo2lpDyA08mDDIQW3vnRC30TKMpBeHb0c6eHTy2/Ked8SHoDojEuI9EiQPhRIkxVCCpBgkQX6dIjfgVEGqkKyGEiTF+N8FqUKyFEqQFEMJkmIoQVIMJUiK4S9iUgwlSIrh2xFSDN8Rk2IoQVIMJUiK+Q8Pd5jx9evw0gAAAABJRU5ErkJggg==" alt="" />

fetch_field_direct

可以传入一个参数fieldnr,也就是字段的位置。效果等效于上面的fetch_fieldfield_seek的配合。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADwCAIAAADdMSzAAAAMy0lEQVR4nO2bXZbcKgyEe/9byqbuDrgPyfh4kFQIWdiiXd/D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EgClBFJgDIiCfwPfd6GFwWusmIAAAAASUVORK5CYII=" alt="" />

2.3、插入更新等信息获取

employees表的主键原先不是自增长的,我后面改了下字段,目前表中有499999条数据。

$sql = "insert into employees(`birth_date`,`first_name`,`last_name`,`gender`,`hire_date`) values ('1988-10-9', 'pw', 'strick', 'M', '1988-10-9')";
$result = $link->query($sql);
var_dump($link->affected_rows);//受影响行数
var_dump($link->insert_id);//主键
//print_r(mysqli_error($link));//打印错误信息

上面的$result返回的将是一个boolean值,而主键和影响行数是需要从mysqli对象中获取。

三、预处理

3.1、添加更新等操作

预处理能有效的防止sql注入的产生,mysqli_stmt是预处理类。

$sql = "insert into employees(`birth_date`,`first_name`,`last_name`,`gender`,`hire_date`) values (?,?,?,?,?)";
$stmt = $link->prepare($sql);//获得预处理对象//bind_param中的第N个参数,必须得用变量赋值
$birth_date = '1989-10-9';$first_name = 'pw2';$last_name = 'strick2';$gender = 'M';$hire_date = '1988-10-9';
$stmt->bind_param('sssss', $birth_date, $first_name, $last_name, $gender, $hire_date);//绑定时使用变量绑定
//$stmt->bind_param('sssss', '1989-10-9', 'pw2', 'strick2', 'M', '1988-10-9');//不能使用这种方式
$stmt->execute();//执行预处理 var_dump($stmt->insert_id);//主键
var_dump($stmt->affected_rows);//受影响行数

prepare

初始化一个预处理对象,传入string类型的查询语句。返回一个mysqli_stmt对象,失败则返回FALSE。

bind_param

绑定预处理查询语句中的变量。第一个参数是指定数据类型。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlEAAACuCAIAAACZRc9sAAAgAElEQVR4nO2dz4sqV/r/P//T2VRtuhcNJpLGhZhAm0XNDdhMTC2k594GcYYeYex8mStc8A64yPUjERwMmE4+Gi4aJjYEJYxIhAKJ1EY3uqldrdz5XRyr6pz6ZentH3bX+8WzaLXq1HPOc+p5e36U/T86AOCwmc/nuVyu0WjM53PbR//7v/+by+X+85//3PlF769kAB6R/3lsBwAAAIAHApoHAAAgLEDzAAAAhAVoHgAAgLBgaV7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0y/FiLmq59Na/VKUJMt9VZ30+2PPNHQXBNc84bq9ebRCOEmVd/3JQLA31uNn3IMq5vMrwoltVSeQ5tnKzTc2jwwxy9XCSSrfMAqmU/TtzcM1joWkwN7YXo5vctZDT/1SdJ+5TaMMylEy3/b4Cjxv5wixbaAzno86iqXL/fm8d51wX1FxuDQ374Zk7ma8HDfSJ9YSlPfNMrm5TAhESDXGTDGOKNjg5lytPTdHyYz7rxp6+8ZBq9g3WoB/8mreL0tHhJwYX9I9I+xbSkCv9u0kNtSbDBvgSSPFx5uPKV9De30Z/LNfkAh6B23SLdHbTThhP9iiVZsWEU6S11379T5gnNfYBNG2gubbndzSk+3+rKVI1Hg6w7u15v2ycSc2xl5p6C7A/1UAgfCfTzkY5sNaSrAesgMABMFvavGZAc0DgThQzZvcXCbK3K16oI4CcMhA8wDgOVApmXdzgpAqbZ41UCfDRg6/EQTArkDzAOCZj4fjLbuwH4f5sJaTjOdlj2KSxxIXAMAbdez3GwfPCmgeAACAsADNAwAAEBageQAAAMICNA8AAEBYgOYBAAAIC9A8AAAAYQGaBwAAICxA8wAAAIQFTvMAAACAZ4yleQAAAMDzBpoHAAAgLEDzAAAAhIX/Dyys8w7M/QgBAAAAAElFTkSuQmCC" alt="" />

3.2、查询

$sql = 'select * from employees limit ?';
$stmt = $link->prepare($sql);
$count = 10;
$stmt->bind_param("i", $count);
$stmt->execute();
$result = $stmt->get_result();//结果集取后的操作就和之前一样了

与上面不同的就是要先preparebind_param,然后execute,最后是get_result获取一个mysqli_result对象,接下来就是和上面的操作一样了。

demo数据库下载:

http://download.csdn.net/detail/loneleaf1/9271903

demo代码下载:

http://ideone.com/uSzZTi

参考资料:

http://segmentfault.com/a/1190000003841357   PHP mysqli 操作数据库

PHP中MySQL操作的更多相关文章

  1. php中mysql操作的buffer知识

    php与mysql的连接有三种方式,mysql,mysqli,pdo.不管使用哪种方式进行连接,都有使用buffer和不使用buffer的区别. 什么叫使用buffer和不使用buffer呢? 客户端 ...

  2. CentOS中Mysql常用操作

    安装mysqlyum -y install mysql-server 修改mysql配置vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记暂时修改一下编码(添加在密码下方) ...

  3. 【转】centOS中mysql一些常用操作

    安装mysql yum -y install mysql-server 修改mysql配置vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记暂时修改一下编码(添加在密码下方 ...

  4. centOS中mysql一些常用操作

      安装mysqlyum -y install mysql-server 修改mysql配置vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记暂时修改一下编码(添加在密码下 ...

  5. 在tornado中使用异步mysql操作

    在使用tornado框架进行开发的过程中,发现tornado的mysql数据库操作并不是一步的,造成了所有用户行为的堵塞.tornado本身是一个异步的框架,要求所有的操作都应该是异步的,但是数据库这 ...

  6. python中的mysql操作

    一. 数据库在自动化测试中的应用 存测试数据 有的时候大批量的数据,我们需要存到数据库中,在测试的时候才能用到,测试的时候就从数据库中读取出来.这点是非常重要的! 存测试结果 二. python中的数 ...

  7. 【科普】MySQL中DDL操作背后的并发原理

    一. 简介 DQL:指数据库中的查询(select)操作. DML:指数据库中的插入(insert).更新(update).删除(delete)等行数据变更操作. DDL:指数据库中加列(add co ...

  8. [转载]大型网站应用中 MySQL 的架构演变史

    没有什么东西是一成不变的,包含我们的理想和生活!MySQL作为一个免费的开源的关系型数据库,深受大家喜爱,从最初的无人问津到当下的去IOE,都体现出了MySQL举足轻重的作用.今天我们就从淘宝的发展来 ...

  9. Mysql操作初级

    Mysql操作初级 本节内容 数据库概述 数据库安装 数据库操作 数据表操作 表内容操作 1.数据库概述 数据库管理系统叫做DBMS 1.什么是数据库 ? 答:数据的仓库,如:在ATM的示例中我们创建 ...

随机推荐

  1. Android进程间通讯之messenger

    这两天在看binder,无意间在文档看到messenger这么个东西,感觉这个东西还挺有意思的,给大家分享一下. 平时一说进程间通讯,大家都会想到AIDL,其实messenger和AIDL作用一样,都 ...

  2. MySQL5.6 GTID新特性实践

    MySQL5.6 GTID新特性实践 GTID简介 搭建 实验一:如果slave所需要事务对应的GTID在master上已经被purge了 实验二:忽略purged的部分,强行同步 本文将简单介绍基于 ...

  3. 利用fsockopen可实现异步成功访问

    $fp = fsockopen("www.jb51.net", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ( ...

  4. [LeetCode] All solution

    比较全的leetcode答案集合: kamyu104/LeetCode grandyang

  5. mysql添加一个用户

    对于添加mysql的远程访问用户,一定要记得刷新刷新系统权限表不然你怎么弄都是不成功的. insert into mysql.user(Host,User,Password) values(" ...

  6. nginx config

    from : http://www.ha97.com/5194.html 更详细的模块参数请参考:http://wiki.nginx.org/Main #定义Nginx运行的用户和用户组user ww ...

  7. Local Desktop

    Desktop: Paradigm System I:\Apps\Admin\ParaStart.bat Paradigm 1 Report Menu  I:\Apps\Admin\ParaStart ...

  8. IOS网络第六天 ASI (略)

    **** 02-ASI01-基本使用(了解) 03-ASI02-其他用法(了解) 04-ASI03-POST请求(了解) 05-ASI04-文件下载(了解) 06-ASI05-文件上传(了解) 07- ...

  9. 修改sql数据库文件 物理文件名称

    -- 允许配置高级选项 EXEC sp_configure 'show advanced options', 1 GO -- 重新配置 RECONFIGURE GO -- 启用xp_cmdshell ...

  10. [学习笔记] Inten