https://github.com/indieteq/PHP-MySQL-PDO-Database-Class

PHP-PDO-MySQL-Class
A PHP MySQL PDO class similar to the the Python MySQLdb. Initialize <?php
define('DBHost', '127.0.0.1');
define('DBName', 'Database');
define('DBUser', 'root');
define('DBPassword', '');
require(dirname(__FILE__)."/src/PDO.class.php");
$DB = new Db(DBHost, DBName, DBUser, DBPassword);
?>
Preventing SQL Injection Attacks Safety: Use parameter binding method Safety Example: <?php
$DB->query("SELECT * FROM fruit WHERE name=?", array($_GET['name']));
?>
Unsafety: Split joint SQL string Unsafety Example: <?php
$DB->query("SELECT * FROM fruit WHERE name=".$_GET['name']);
?>
Usage table "fruit" id name color
apple red
banana yellow
watermelon green
pear yellow
strawberry red
Fetching with Bindings (ANTI-SQL-INJECTION): <?php
$DB->query("SELECT * FROM fruit WHERE name=? and color=?",array('apple','red'));
$DB->query("SELECT * FROM fruit WHERE name=:name and color=:color",array('name'=>'apple','color'=>'red'));
?>
Result: Array
(
[] => Array
(
[id] =>
[name] => apple
[color] => red
)
)
WHERE IN: <?php
$DB->query("SELECT * FROM fruit WHERE name IN (?)",array('apple','banana'));
?>
Result: Array
(
[] => Array
(
[id] =>
[name] => apple
[color] => red
)
[] => Array
(
[id] =>
[name] => banana
[color] => yellow
)
)
Fetching Column: <?php
$DB->column("SELECT color FROM fruit WHERE name IN (?)",array('apple','banana','watermelon'));
?>
Result: Array
(
[] => red
[] => yellow
[] => green
)
Fetching Row: <?php
$DB->row("SELECT * FROM fruit WHERE name=? and color=?",array('apple','red'));
?>
Result: Array
(
[id] =>
[name] => apple
[color] => red
)
Fetching single: <?php
$DB->single("SELECT color FROM fruit WHERE name=? ",array('watermelon'));
?>
Result: green
Delete / Update / Insert These operations will return the number of affected result set. (integer) <?php
// Delete
$DB->query("DELETE FROM fruit WHERE id = :id", array("id"=>""));
$DB->query("DELETE FROM fruit WHERE id = ?", array(""));
// Update
$DB->query("UPDATE fruit SET color = :color WHERE name = :name", array("name"=>"strawberry","color"=>"yellow"));
$DB->query("UPDATE fruit SET color = ? WHERE name = ?", array("yellow","strawberry"));
// Insert
$DB->query("INSERT INTO fruit(id,name,color) VALUES(?,?,?)", array(null,"mango","yellow"));//Parameters must be ordered
$DB->query("INSERT INTO fruit(id,name,color) VALUES(:id,:name,:color)", array("color"=>"yellow","name"=>"mango","id"=>null));//Parameters order free
?>
Get Last Insert ID <?php
$DB->lastInsertId();
?>
Get the number of queries since the object initialization <?php
$DB->querycount;
?>
Close Connection <?php
$DB->CloseConnection;
?>

https://github.com/fightbulc/simplon_mysql

Dependecies

PHP >= 5.3
PDO
. Installing Easy install via composer. Still no idea what composer is? Inform yourself here. {
"require": {
"simplon/mysql": "*"
}
}
. Direct vs. SqlManager I implemented two different ways of interacting with MySQL. The first option is the usual one which interacts directly with the database. Following a straight forward example to show you what I mean: $dbConn->fetchRow('SELECT * FROM names WHERE name = :name', array('name' => 'Peter'));
In constrast to the prior method the SqlManager uses a Builder Pattern to deal with the database. What advantage does that offer? Well, in case that we want to do more things with our query before sending it off we encapsule it as a Builder Pattern. From there on we could pass it throughout our application to add more data or alike before sending the query finally off to the database. Again, a quick example of how we would rewrite the above direct query: $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setQuery('SELECT * FROM names WHERE name = :name')
->setConditions(array('name' => 'Peter')); $sqlManager = new \Simplon\Mysql\Manager\SqlManager($dbConn);
$sqlManager->fetchRow($sqlBuilder);
. Setup connection The library requires a config value object in order to instantiate a connection with MySQL. See how it's done: $config = array(
// required credentials 'host' => 'localhost',
'user' => 'rootuser',
'password' => 'rootuser',
'database' => 'our_database', // optional 'fetchMode' => \PDO::FETCH_ASSOC,
'charset' => 'utf8',
'port' => ,
'unixSocket' => null,
); // standard setup
$dbConn = new \Simplon\Mysql\Mysql(
$config['host'],
$config['user'],
$config['password'],
$config['database']
);
The following code shows all possible parameters to setup a connection: \Simplon\Mysql\Mysql::__construct(
$host,
$user,
$password,
$database,
$fetchMode = \PDO::FETCH_ASSOC,
$charset = 'utf8',
array $options = array('port' => , 'unixSocket' => '')
);
In case that you wanna use the SqlManager there is one piece missing: $sqlManager = new \Simplon\Mysql\Manager\SqlManager($dbConn);
. Usage: Direct access 4.1. Query FetchColumn Returns a selected column from the first match. The example below returns id or null if nothing was found. $result = $dbConn->fetchColumn('SELECT id FROM names WHERE name = :name', array('name' => 'Peter')); // result
var_dump($result); // '1' || null
FetchColumnMany Returns an array with the selected column from all matching datasets. In the example below an array with all ids will be returned or null if nothing was found. $result = $dbConn->fetchColumnMany('SELECT id FROM names WHERE name = :name', array('name' => 'Peter')); // result
var_dump($result); // ['1', '15', '30', ...] || null
FetchColumnManyCursor Returns one matching dataset at a time. It is resource efficient and therefore handy when your result has many data. In the example below you either iterate through the foreach loop in case you have matchings or nothing will happen. $cursor = $dbConn->fetchColumnMany('SELECT id FROM names WHERE name = :name', array('name' => 'Peter')); foreach ($cursor as $result)
{
var_dump($result); // '1'
}
FetchRow Returns all selected columns from a matched dataset. The example below returns id, age for the matched dataset. If nothing got matched null will be returned. $result = $dbConn->fetchRow('SELECT id, age FROM names WHERE name = :name', array('name' => 'Peter')); var_dump($result); // ['id' => '1', 'age' => '22'] || null
FetchRowMany Returns all selected columns from all matched dataset. The example below returns for each matched dataset id, age. If nothing got matched null will be returned. $result = $dbConn->fetchRowMany('SELECT id, age FROM names WHERE name = :name', array('name' => 'Peter')); var_dump($result); // [ ['id' => '1', 'age' => '22'], ['id' => '15', 'age' => '40'], ... ] || null
FetchRowManyCursor Same explanation as for FetchColumnManyCursor except that we receive all selected columns. $result = $dbConn->fetchRowMany('SELECT id, age FROM names WHERE name = :name', array('name' => 'Peter')); foreach ($cursor as $result)
{
var_dump($result); // ['id' => '1', 'age' => '22']
}
4.2. Insert Single data Inserting data into the database is pretty straight forward. Follow the example below: $data = array(
'id' => false,
'name' => 'Peter',
'age' => ,
); $id = $dbConn->insert('names', $data); var_dump($id); // 50 || bool
The result depends on the table. If the table holds an autoincrementing ID column you will receive the ID count for the inserted data. If the table does not hold such a field you will receive true for a successful insert. If anything went bogus you will receive false. Many datasets Follow the example for inserting many datasets at once: $data = array(
array(
'id' => false,
'name' => 'Peter',
'age' => ,
),
array(
'id' => false,
'name' => 'Peter',
'age' => ,
),
); $id = $dbConn->insertMany('names', $data); var_dump($id); // 50 || bool
The result depends on the table. If the table holds an autoincrementing ID column you will receive the ID count for the inserted data. If the table does not hold such a field you will receive true for a successful insert. If anything went bogus you will receive false. 4.3. Updating Simple update statement Same as for insert statements accounts for updates. Its easy to understand. If the update succeeded the response will be true. If nothing has been updated you will receive null. $conds = array(
'id' => ,
); $data = array(
'name' => 'Peter',
'age' => ,
); $result = $dbConn->update('names', $conds, $data); var_dump($result); // true || null
Custom update conditions query Same as for insert statements accounts for updates. Its easy to understand. If the update succeeded the response will be true. If nothing has been updated you will receive null. $conds = array(
'id' => ,
'name' => 'Peter',
); // custom conditions query
$condsQuery = 'id = :id OR name =: name'; $data = array(
'name' => 'Peter',
'age' => ,
); $result = $dbConn->update('names', $conds, $data, $condsQuery); var_dump($result); // true || null
4.4. Replace As MySQL states it: REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted. Replace a single datasets As a result you will either receive the INSERT ID or false in case something went wrong. $data = array(
'id' => ,
'name' => 'Peter',
'age' => ,
); $result = $dbConn->replace('names', $data); var_dump($result); // 1 || false
Replace multiple datasets As a result you will either receive an array of INSERT IDs or false in case something went wrong. $data = array(
array(
'id' => ,
'name' => 'Peter',
'age' => ,
),
array(
'id' => ,
'name' => 'John',
'age' => ,
),
); $result = $dbConn->replaceMany('names', $data); var_dump($result); // [5, 10] || false
4.5. Delete Simple delete conditions The following example demonstrates how to remove data. If the query succeeds we will receive true else false. $result = $dbConn->delete('names', array('id' => )); var_dump($result); // true || false
Custom delete conditions query The following example demonstrates how to remove data with a custom conditions query. If the query succeeds we will receive true else false. $conds = array(
'id' => ,
'name' => 'John',
); // custom conditions query
$condsQuery = 'id = :id OR name =: name'; $result = $dbConn->delete('names', $conds, $condsQuery); var_dump($result); // true || false
4.6. Execute This method is ment for calls which do not require any parameters such as TRUNCATE. If the call succeeds you will receive true. If it fails an MysqlException will be thrown. $result = $dbConn->executeSql('TRUNCATE names'); var_dump($result); // true
. Usage: SqlManager The following query examples will be a rewrite of the aforementioned direct access examples. Remember: We need an instance of the SqlManager. Paragraph . Setup connection shows how to get your hands on it. 5.1. Query FetchColumn Returns a selected column from the first match. In the example below id will be returned or null if nothing was found. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setQuery('SELECT id FROM names WHERE name = :name')
->setConditions(array('name' => 'Peter')); $result = $sqlManager->fetchColumn($sqlBuilder); // result
var_dump($result); // '1' || null
FetchColumnMany Returns an array with the selected column from all matching datasets. In the example below an array with all ids will be returned or null if nothing was found. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setQuery('SELECT id FROM names WHERE name = :name')
->setConditions(array('name' => 'Peter')); $result = $sqlManager->fetchColumnMany($sqlBuilder); // result
var_dump($result); // ['1', '15', '30', ...] || null
FetchColumnManyCursor Returns one matching dataset at a time. It is resource efficient and therefore handy when your result has many data. In the example below you either iterate through the foreach loop in case you have matchings or nothing will happen. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setQuery('SELECT id FROM names WHERE name = :name')
->setConditions(array('name' => 'Peter')); foreach ($sqlManager->fetchColumnMany($sqlBuilder) as $result)
{
var_dump($result); // '1'
}
FetchRow Returns all selected columns from a matched dataset. The example below returns id, age for the matched dataset. If nothing got matched null will be returned. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setQuery('SELECT id, age FROM names WHERE name = :name')
->setConditions(array('name' => 'Peter')); $result = $sqlManager->fetchRow($sqlBuilder); var_dump($result); // ['id' => '1', 'age' => '22'] || null
FetchRowMany Returns all selected columns from all matched dataset. The example below returns for each matched dataset id, age. If nothing got matched null will be returned. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setQuery('SELECT id, age FROM names WHERE name = :name')
->setConditions(array('name' => 'Peter')); $result = $sqlManager->fetchRowMany($sqlBuilder); var_dump($result); // [ ['id' => '1', 'age' => '22'], ['id' => '15', 'age' => '40'], ... ] || null
FetchRowManyCursor Same explanation as for FetchColumnManyCursor except that we receive all selected columns. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setQuery('SELECT id, age FROM names WHERE name = :name')
->setConditions(array('name' => 'Peter')); foreach ($sqlManager->fetchRowManyCursor($sqlBuilder) as $result)
{
var_dump($result); // ['id' => '1', 'age' => '22']
}
5.2. Insert Single data Inserting data into the database is pretty straight forward. Follow the example below: $data = array(
'id' => false,
'name' => 'Peter',
'age' => ,
); $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setTableName('names')
->setData($data); $id = $sqlManager->insert($sqlBuilder); var_dump($id); // 50 || false
The result depends on the table. If the table holds an autoincrementing ID column you will receive the ID count for the inserted data. If the table does not hold such a field you will receive true for a successful insert. If anything went bogus you will receive false. Many datasets Follow the example for inserting many datasets at once: $data = array(
array(
'id' => false,
'name' => 'Peter',
'age' => ,
),
array(
'id' => false,
'name' => 'Peter',
'age' => ,
),
); $sqlBuilder = (new \Simplon\Mysql\Manager\SqlQueryBuilder())
->setTableName('names')
->setData($data); $result = $sqlManager->insert($sqlBuilder); var_dump($id); // [50, 51, ...] || false
The result depends on the table. If the table holds an autoincrementing ID column you will receive the ID count for the inserted data. If the table does not hold such a field you will receive true for a successful insert. If anything went bogus you will receive false. 5.3. Update Simple update statement Same as for insert statements accounts for updates. Its easy to understand. If the update succeeded the response will be true. If nothing has been updated you will receive null. $data = array(
'name' => 'Peter',
'age' => ,
); $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setTableName('names')
->setConditions(array('id' => ))
->setData($data); $result = $sqlManager->update($sqlBuilder); var_dump($result); // true || null
Custom update conditions query Same as for insert statements accounts for updates. Its easy to understand. If the update succeeded the response will be true. If nothing has been updated you will receive null. $data = array(
'name' => 'Peter',
'age' => ,
); $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setTableName('names')
->setConditions(array('id' => ))
->setConditionsQuery('id = :id OR name =: name')
->setData($data) $result = $sqlManager->update($sqlBuilder); var_dump($result); // true || null
5.4. Replace As MySQL states it: REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted. Replace a single datasets As a result you will either receive the INSERT ID or false in case something went wrong. $data = array(
'id' => ,
'name' => 'Peter',
'age' => ,
); $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setTableName('names')
->setData($data); $result = $sqlManager->replace($sqlBuilder); var_dump($result); // 1 || false
Replace multiple datasets As a result you will either receive an array of INSERT IDs or false in case something went wrong. $data = array(
array(
'id' => ,
'name' => 'Peter',
'age' => ,
),
array(
'id' => ,
'name' => 'John',
'age' => ,
),
); $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setTableName('names')
->setData($data); $result = $sqlManager->replaceMany($sqlBuilder); var_dump($result); // [5, 10] || false
5.5. Delete Simple delete conditions The following example demonstrates how to remove data. If the query succeeds we will receive true else false. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setTableName('names')
->setConditions(array('id' => )); $result = $sqlManager->delete($sqlBuilder); var_dump($result); // true || false
Custom delete conditions query The following example demonstrates how to remove data with a custom conditions query. If the query succeeds we will receive true else false. $sqlBuilder = new \Simplon\Mysql\Manager\SqlQueryBuilder(); $sqlBuilder
->setTableName('names')
->setConditions(array('id' => , 'name' => 'Peter'))
->setConditionsQuery('id = :id OR name =: name'); $result = $sqlManager->delete($sqlBuilder); var_dump($result); // true || false
. IN() Clause Handling 6.1. The issue There is no way using an IN() clause via PDO. This functionality is simply not given. However, you could do something like the following: $ids = array(,,,,);
$query = "SELECT * FROM users WHERE id IN (" . join(',', $ids) . ")";
Looks good at first sight - not sexy but probably does the job, right? Wrong. This approach only works with INTEGERS and it does not ESCAPE the user's input - the reason why we use PDO in first place. Just for the record here is a string example which would not work: $emails = array('johnny@me.com', 'peter@ibm.com');
$query = "SELECT * FROM users WHERE email IN (" . join(',', $emails) . ")";
The only way how this would work is by wrapping each value like the following: '"email"'. Way too much work. 6.2. The solution To take advantage of the built in IN() Clause with escaping and type handling do the following: // integers
$conds = array('ids' => array(,,,,));
$query = "SELECT * FROM users WHERE id IN (:ids)"; // strings
$conds = array('emails' => array('johnny@me.com', 'peter@ibm.com'));
$query = "SELECT * FROM users WHERE email IN (:emails)";
. CRUD Helper (CONTENT IS OUTDATED. UPDATE WILL FOLLLOW) 7.1. Intro CRUD stands for Create Read Update Delete and reflects the for basic functions for persisent storage. I found myself writing more and more CRUDs for all my object/database interactions simply for the reason of having a SINGLE POINT OF ACCESS when I was interacting with these objects for above mentioned functions. Eventually, it has sort of a touch of a database model but with more flexibility. Also, we keep writing VALUE OBJECTS and by that we keep the red line for all our code base. Note: VALUE OBJECTS are actually MODELS while models are not value objects. The reason for this is that a value object is vehicle for all sorts of data while models are only vehicles for database data. At least that's what it should be. 7.2. Requirements/Restrictions There are really not many requirements/restrictions: Instance of SqlCrudManager - requires an instance of Simplon\Mysql.
Value object needs to extend from SqlCrudVo
Table name should be in plural or set it via SqlCrudVo::$crudSource within the value object.
Value object's instance variables must match the table's column names in CamelCase (see example below).
Each value object reflects ONE OBJECT only - Mysql::fetchRow() fetches your data.
VARIABLE = COLUMN Don't set any property in your value object which doesn't reflect your database table. If you have to, make either use of SqlCrudVo::crudColumns() or SqlCrudVo::crudIgnore(). See Flexibility for description.
7.3. Flexibility Set source: In case you have a table name which can't be easily pluralised (e.g. person/people) you can set the source yourself via SqlCrudVo::$crudSource within value object Set custom read query: In case you need a custom query to get your object you can set it when you instantiate the object new SqlCrudVo($query) or simply within your __construct() { parent::construct($query); }. Callbacks: You can implement two methods which will be called prior/after saving an object: SqlCrudVo::crudBeforeSave($isCreateEvent) and SqlCrudVo::crudAfterSave($isCreateEvent). The manager will pass you a boolean to let you know what type of save process happens/happened. You could use this e.g. to set automatically created_at and updated_at fields. Set columns: If you have to either match property- and column name or only want a selection of your properties make use of SqlCrudVo::crudColumns() within your value object. It should return an array where the ARRAY KEY reflects the value object's VARIABLE NAME and the ARRAY VALUE the COLUMN NAME. Example: array('createdAt' => 'created_at') Ignore properties: Considering the prior point you could do the reverse and simply IGNORE VARIABLES. For that implement SqlCrudVo::crudIgnore() which should return an array of properties you would like to ignore. No assumptions: There are no assumptions about primary keys or anything alike. You set all conditions for reading, updating and/or deleting objects. Casted values: Thanks to your value object which is always in between you and your database you can cast all values - good bye STRING CASTED ONLY values. 7.4. Conclusion That's all what is needed - at least for now. It's simple, explicit and flexible enough not to restrict you in your requirements respectively your creativity. 7.5. Examples Enough talk, bring it on! Alright, what is needed? Lets assume we have a database table called users and a value object called UserVo. Note: the value object name has to be the singular of the table's plural name. Here is the table schema: CREATE TABLE `users` (
`id` int() unsigned NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
`email` varchar() NOT NULL DEFAULT '',
`created_at` int() unsigned NOT NULL,
`updated_at` int() unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8;
... and here is our value object for the given table: class UserVo extends \Simplon\Mysql\Crud\SqlCrudVo
{
protected $id;
protected $name;
protected $email;
protected $createdAt;
protected $updatedAt; // ... here goes getter/setter for the above variables
}
Now, lets do some CRUD, baby! For all processes we need an instance of our SqlCrudManager: /**
* construct it with an instance of your simplon/mysql
*/
$sqlCrudManager = new \Simplon\Mysql\Crud\SqlCrudManager($mysqlInstance);
Create a user: $userVo = new UserVo(); $userVo
->setId(null)
->setName('Johnny Foobar')
->setEmail('foo@bar.com'); /** @var UserVo $userVo */
$userVo = $sqlCrudManager->create($userVo); // print insert id
echo $userVo->getId(); //
Read a user: // conditions: where id = 1
$conds = array('id' => ); /** @var UserVo $userVo */
$userVo = $sqlCrudManager->read(new UserVo(), $conds); // print name
echo $userVo->getName(); // Johnny Foobar
Update a user: // conditions: where id = 1
$conds = array('id' => ); /** @var UserVo $userVo */
$userVo = $sqlCrudManager->read(new UserVo(), $conds); // set new name
$userVo->setName('Hansi Hinterseher'); // update
/** @var UserVo $userVo */
$userVo = $sqlCrudManager->update($userVo, $conds); // print name
echo $userVo->getName(); // Hansi Hinterseher
Delete a user: // conditions: where id = 1
$conds = array('id' => ); /**
* UserVo::crudGetSource() is the name of the table
* based on the value object's name
*/
$sqlCrudManager->update(UserVo::crudGetSource(), $conds);
7.6. Example Custom Vo Setting a custom table name since the plural from person is not persons: class PersonVo extends \Simplon\Mysql\Crud\SqlCrudVo
{
/**
* @return string
*/
public static function crudGetSource()
{
return 'people';
} // ... here goes the rest
}
In case your column names are totally off there is a way to match them anyway against your properties: class UserVo extends \Simplon\Mysql\Crud\SqlCrudVo
{
protected $id;
protected $name;
protected $email;
protected $createdAt;
protected $updatedAt; /**
* @return array
*/
public function crudColumns()
{
return array(
'id' => 'xx_id',
'name' => 'xx_name',
'email' => 'xx_email',
'createdAt' => 'xx_created_at',
'updatedAt' => 'xx_updated_at',
);
} // ... here goes the rest
}
Sometimes there are some helper properties which are not part of your database entry. Here is a way to ignore them: class UserVo extends \Simplon\Mysql\Crud\SqlCrudVo
{
protected $id;
protected $name;
protected $email;
protected $createdAt;
protected $updatedAt; // helper property: not part of the people table
protected $isOffline; /**
* @return array
*/
public function crudIgnore()
{
return array(
'isOffline',
);
} // ... here goes the rest
}
. Exceptions For both access methods (direct, sqlmanager) occuring exceptions will be wrapped by a MysqlException. All essential exception information will be summarised as JSON within the Exception Message. Here is an example of how that might look like: {"query":"SELECT pro_id FROM names WHERE connector_type = :connectorType","params":{"connectorType":"FB"},"errorInfo":{"sqlStateCode":"42S22","code":,"message":"Unknown column 'pro_id' in 'field list'"}}
License
Simplon/Mysql is freely distributable under the terms of the MIT license. Copyright (c) Tino Ehrich (tino@bigpun.me) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

PHP PDO_MYSQL 操作类 YAF嵌入高性能类而准备的更多相关文章

  1. Java操作文件夹的工具类

    Java操作文件夹的工具类 import java.io.File; public class DeleteDirectory { /** * 删除单个文件 * @param fileName 要删除 ...

  2. 危险代码:如何使用Unsafe操作内存中的Java类和对象

    危险代码:如何使用Unsafe操作内存中的Java类和对象—Part1 危险代码:如何使用Unsafe操作内存中的Java类和对象—Part2 危险代码:如何使用Unsafe操作内存中的Java类和对 ...

  3. 高并发分布式系统中生成全局唯一(订单号)Id js返回上一页并刷新、返回上一页、自动刷新页面 父页面操作嵌套iframe子页面的HTML标签元素 .net判断System.Data.DataRow中是否包含某列 .Net使用system.Security.Cryptography.RNGCryptoServiceProvider类与System.Random类生成随机数

    高并发分布式系统中生成全局唯一(订单号)Id   1.GUID数据因毫无规律可言造成索引效率低下,影响了系统的性能,那么通过组合的方式,保留GUID的10个字节,用另6个字节表示GUID生成的时间(D ...

  4. C#操作Xml树的扩展类

    本文提供一个操作Xml树的扩展类,与将xml字符串直接映射成实体对象的使用方法,供大家参考,学习. 下面附上源码 using System; using System.Collections.Gene ...

  5. java 中操作字符串都有哪些类?(未完成)它们之间有什么区别?(未完成)

    java 中操作字符串都有哪些类?(未完成)它们之间有什么区别?(未完成)

  6. 序列化多表操作、请求与响应、视图组件(子类与拓展类)、继承GenericAPIView类重写接口

    今日内容概要 序列化多表操作 请求与相应 视图组件 内容详细 1.序列化多表操作 模型类 models.py中 # 新建django项目 # 创建表 模型类models.py中: from djang ...

  7. 07_数据库创建,添加c3p0操作所需的jar包,编写c3p0-config.xml文件,编写User.java,编写jdbcUtils.java实现操作数据库的模板工具类,UserDao编写,Dao

     1  创建day14数据库,创建user.sql表: A 创建数据库 day14 B 创建数据表 users create table users ( id int primary keyaut ...

  8. 继承的综合运用《Point类派生出Circle类而且进行各种操作》

    类的组合与继承 (1)先建立一个Point(点)类.包括数据成员x,y(坐标点). (2)以Point为基类.派生出一个Circle(圆)类,添加数据成员(半径),基类的成员表示圆心: (3)编写上述 ...

  9. Discuz!数据库操作DB类和C::t类介绍

    类定义文件 DB类: 文件\source\class\class_core.php class DB extends discuz_database {} discuz_database类定义 文件\ ...

随机推荐

  1. MongoDB 学习笔记(三)—— 修改器的使用

    通常文档只会有一部分数据要更新,所以使用修改器来操作文档极为高效. 小技巧:了解函数功能,不带括号即可.如:db.blog.update即可查看update函数的具体参数和方法体. $set修改器 & ...

  2. shell字符串的截取

    1.变量 var 从 npos ∈ [0, length-1] 位开始,从左->右截取 num 个字符: ${var:npos:num} / ${var:npos} 小结:若 npos < ...

  3. NFC framework

    NFC framework introduce 1 NFC简介 对于NFC,是google在android4.0上推出来的,简单介绍下.近场通讯(NFC)是一系列短距离无线技术,一般需要4cm或者更短 ...

  4. WordPress实现长篇文章/日志/单页面分页功能效果

    在WordPress里写文章,如果内容很多,你可能想要把文章分成几页来让访客浏览,这样既保持了网页的美观,也提高了网页的打开速度.但是在WordPress默认提供的按钮里,你可能找不到文章分页功能所对 ...

  5. ExtJS 提示

    要使ExtJS支持提示,需要在onReady的function中添加如下语句: Ext.QuickTips.init();//支持tips提示 Ext.form.Field.prototype.msg ...

  6. 浅谈.NET中闭包

    什么是闭包 闭包可以从而三个维度来说明.在编程语言领域,闭包是指由函数以及与函数相关的上下文环境组合而成的实体.通过闭包,函数与其上下文变量之间建立起关联关系,上下文变量的状态可以在函数的多次调用过程 ...

  7. 006--VS2013 C++ 加载其他格式图片,并显示半透明化

    //--------------------------------------------MyPaint() 函数------------------------------------------ ...

  8. Python实现SVM(支持向量机)

    Python实现SVM(支持向量机) 运行环境 Pyhton3 numpy(科学计算包) matplotlib(画图所需,不画图可不必) 计算过程 st=>start: 开始 e=>end ...

  9. [原]Java修炼 之 基础篇(二)Java语言构成

    上次的博文中Java修炼 之 基础篇(一)Java语言特性我们介绍了一下Java语言的几个特性,今天我们介绍一下Java语言的构成.        所谓的Java构成,主要是指Java运行环境的组成, ...

  10. online training

    https://www.skillfeed.com/browse http://teamtreehouse.com/features http://www.pluralsight.com/ https ...