<?xml version="1.0"?><phpdoc><class name="Bs_DbWrapper" extends="Bs_Object" undoc="false" access="public" package="db"><file>C:/usr/local/lib/php/blueshoes-4.2/core/db/Bs_DbWrapper.class.php</file><doc><author>andrej arn &amp;lt;andrej at blueshoes dot org&amp;gt;</author><author>samuel blume &amp;lt;sam at blueshoes dot org&amp;gt;</author><inherited src="Array"/><description>todo:this class is old and needs some major cleaning. especially more down the file.i think that some methods should be moved into a new Bs_DbUtil class. maybe:rlArrayToHashArray(), sqlPrepareByArray(), sqlArrayToOrderBy()i took the old class and made the needed changes to get it running, not more.28.2.2002 --andrejdependencies:</description><shortdescription>DB Wrapper</shortdescription><version>4.0.$id$</version><copyright>blueshoes.org</copyright></doc><function name="Bs_DbWrapper" undoc="false" access="public"><doc><return type="void"/><description/><shortdescription>constructor</shortdescription></doc></function><function name="setDbTableName" undoc="false" access="public"><doc><parameter name="$tableName" undoc="true"/><return type="void"/><description>no check is made if that table exists.</description><shortdescription>sets the table name that should be used.</shortdescription></doc></function><function name="&amp;getData" undoc="false" access="public"><doc><see type="var">$_recordData</see><parameter name="$key" default="null" type="string">(default is null. case sensitive.)</parameter><return name="" type="mixed"> &amp;(array or string)</return><throws>null on an unknown key. the key is case sensitive.</throws><description>if the param $key is not set or set to null, the whole data array will be returned.you may bet the value by reference.</description><shortdescription>returns the desirec data.</shortdescription></doc></function><function name="_isInitialized" undoc="false" access="private"><doc><return name="" type="bool"/><description/><shortdescription>tells if the wrapper has been initialized and is ready to use.</shortdescription></doc></function><function name="_hasData" undoc="false" access="private"><doc><return type="void"/><description/><shortdescription>tells if the object has any data.</shortdescription></doc></function><function name="initByID" undoc="false" access="public"><doc><see type="function">initByData()</see><parameter name="$id" type="string">(the identifier of the table. (The ID field))</parameter><parameter name="$idFieldName" default="&amp;apos;ID&amp;apos;" type="string">(default is &amp;apos;ID&amp;apos;. if your field is called different, change that.)</parameter><return name="" type="bool"/><description/><shortdescription>Init by fetching the data from the DB and then call $this-&amp;gt;initByData().</shortdescription></doc></function><function name="initByData" undoc="false" access="private"><doc><parameter name="$data" type="array">(hash from db-select =&amp;gt; record data.)</parameter><return name="" type="bool"/><description/><shortdescription>init using the result set (as array).</shortdescription></doc></function><function name="dbInsert" undoc="false" access="public"><doc><return name="" type="int"> (new record id)</return><throws>bool FALSE (not initialized</throws><throws>no data) or bs_exception (db problem/failure)</throws><description>It expects the primery Key to be called &amp;quot;ID&amp;quot;, which must be temporarlyremoved to execute the SQL INSERT successfully.Also a field named &amp;quot;timestap&amp;quot; will be temp. removed.</description><shortdescription>Insert a new set of data (record) into the DB.</shortdescription></doc></function><function name="dbUpdate" undoc="false" access="public"><doc><return name="" type="bool">TRUE </return><throws>bool FALSE (not initialized</throws><throws>no data) or bs_exception (db problem/failure)</throws><description/><shortdescription>Replace an existing record or, if not existent, insert a new one.</shortdescription></doc></function><function name="dbDelete" undoc="false" access="public"><doc><return name="" type="bool">TRUE </return><throws>bool FALSE (not initialized</throws><throws>no data) or bs_exception (db problem/failure)</throws><description/><shortdescription>Delete the record from the DB.</shortdescription></doc></function><function name="_extractTablesFromStr" undoc="false" access="private"><doc><parameter name="$sqlStr" type="string" undoc="true"/><return name="" type="array"> (hash where key is the table name, value is bool TRUE.)</return><description>finds things like db.table.field and table.field.i don&amp;apos;t think this one will check &amp;quot;SELECT blah FROM table, table, table&amp;quot; ... dunno. --andrej</description><shortdescription>Extracts all table names of a SQL clause.</shortdescription></doc></function><function name="dbCount" undoc="false" access="public"><doc><parameter name="$whereCondition" type="string">(see above)</parameter><parameter name="$selectAddition" default="&amp;apos;&amp;apos;" type="string">(see above)</parameter><return name="" type="string"/><throws>bool FALSE (not initialized) or bs_exception (db problem/failure)</throws><description>put them into a comma separated list.//FROM &amp;lt;tab1&amp;gt;,&amp;lt;tab2&amp;gt; part of the sql query string.param $whereCondition:&amp;quot;WHERE db.table.field = &amp;apos;foo&amp;apos; AND table.field = &amp;apos;bar&amp;apos;&amp;quot;param $selectAddition:&amp;quot;db.table.field, table.field, field, &amp;quot;hrm. dunno exactly what&amp;apos;s going on here. --andrej</description><shortdescription>If dbCount finds any foreign tables in the where clause then it will</shortdescription></doc></function><function name="getRecordList" undoc="false" access="private"><doc><parameter name="$fieldArray" type="array">[$fieldArray]; field list, example &amp;quot;firstName&amp;quot;, default = select all fields</parameter><parameter name="$whereCondition" default="&amp;quot;&amp;quot;" type="string">[$whereCondition]; where conditions, example &amp;quot;WHERE firstName LIKE &amp;apos;%tobler%&amp;apos; AND (ID &amp;gt;= 15 OR someShit = &amp;apos;hello&amp;apos;)&amp;quot;,</parameter><parameter name="&amp;$orderArray" type="string">[$orderArray]; fieldnames for order by, example array(&amp;quot;firstName&amp;quot; =&amp;gt; &amp;quot;DESC&amp;quot;), default = no order</parameter><parameter name="$offset" default="0" type="integer">[$offset]; first record, where to start, example 20, default = no offset</parameter><parameter name="$maxAmount" default="-1" type="integer">[$maxAmount]; number of records to get, example 50, default = all</parameter><parameter name="$selectAddition" type="string" undoc="true"/><return name="" type="array"> (2d array with the records. output that we got from db-&amp;gt;getAll().)</return><throws>bool FALSE (not initialized) or bs_exception (db problem/failure)</throws><description>//FROM &amp;lt;tab1&amp;gt;,&amp;lt;tab2&amp;gt; part of the sql query string.</description><shortdescription>//If getRecordList finds any foreign tables in the where clause OR in the fieldArray, it will put it in the the</shortdescription></doc></function><function name="sqlPrepareByArray" undoc="false" access="private"><doc><parameter name="$sqlFormatStr" default="&amp;quot;&amp;quot;" type="string">: A sql string with 1 (one) %s (string placeholders)</parameter><parameter name="&amp;$theArray" type="array">: Normal or hash array (see above) with dbField and value pair (as given from $this-&amp;gt;FArray())&#x0a;&#x0a;Examples SELECT&#x0a;The Array:  array(&amp;quot;ID&amp;quot;=&amp;gt;41, &amp;quot;TXT&amp;quot;=&amp;gt;&amp;quot;sample 1&amp;quot;, &amp;quot;whatEver&amp;quot;=&amp;gt;&amp;quot;oooo&amp;quot;)&#x0a;or:  array(&amp;quot;ID&amp;quot;, &amp;quot;TXT&amp;quot;, &amp;quot;whatEver&amp;quot;)&#x0a;A) SELECT %s FROM [WHERE where_definition] [LIMIT #]&#x0a;Will return&#x0a;A) SELECT ID,TXT,whatEver FROM [WHERE where_definition] [LIMIT #]&#x0a;&#x0a;Examples INSERT, REPLACE or UPDATE&#x0a;The Array:  array(&amp;quot;ID&amp;quot;=&amp;gt;41, &amp;quot;TXT&amp;quot;=&amp;gt;&amp;quot;sample 1&amp;quot;, &amp;quot;whatEver&amp;quot;=&amp;gt;&amp;quot;oooo&amp;quot;)&#x0a;A) UPDATE db.table SET %s [WHERE where_definition] [LIMIT #]&#x0a;B) INSERT [INTO] tbl_name SET %s&#x0a;Will return&#x0a;A) UPDATE db.table SET ID=&amp;apos;41&amp;apos;,TXT=&amp;apos;sample 1&amp;apos;,whatEver=&amp;apos;oooo&amp;apos; [WHERE where_definition] [LIMIT #]&amp;quot;&#x0a;B) INSERT [INTO] tbl_name SET ID=&amp;apos;41&amp;apos;,TXT=&amp;apos;sample 1&amp;apos;,whatEver=&amp;apos;oooo&amp;apos;</parameter><return type="void"/><description>This fuction expects $sqlFormatStr of th forma)  [INSERT | REPLACE | UPDATE] table SET %s [what ever];b)  SELECT %s [what ever];In case of a) the Array ($theArray) MUST be a hash Array of field value pair.In case of b) the Array ($theArray) MAY be either and normal Array of fields or hash Array of field value pair.See example.</description><shortdescription>Usefull INTELLIGENT helper to built a SELECT, INSERT, REPLACE and UPDATE (maybe more) sql string.</shortdescription></doc></function><function name="sqlArrayToOrderBy" undoc="false" access="private"><doc><parameter name="&amp;$theArray" type="array">MAY be either and normal or hash Array. If hash array({&amp;quot;fieldName&amp;quot;=&amp;gt;[ &amp;quot;&amp;quot; | &amp;quot;ASC&amp;quot; | &amp;quot;DESC&amp;quot;]})</parameter><return type="void"/><description>Expects the passed array ($theArray) to be either a normal array of fields or a hash Arrayof the form array({&amp;quot;fieldName&amp;quot;=&amp;gt;[ &amp;quot;&amp;quot; | &amp;quot;ASC&amp;quot; | &amp;quot;DESC&amp;quot;]}).It will then  build the SQL fragment ORDER BY  {&amp;lt;field Name&amp;gt; [&amp;lt;order key&amp;gt;]}Examples AGiven: array( &amp;quot;name&amp;quot;=&amp;gt;&amp;quot;&amp;quot;, &amp;quot;ID&amp;quot;=&amp;gt;&amp;quot;ASC&amp;quot;, &amp;quot;time&amp;quot;=&amp;gt;&amp;quot;DESC&amp;quot;)Return: &amp;quot; ORDER BY name,ID ASC,time DESC &amp;quot;Examples BGiven: array( &amp;quot;name&amp;quot;, &amp;quot;ID&amp;quot;, &amp;quot;time&amp;quot;)Return: &amp;quot; ORDER BY name,ID,time &amp;quot;</description><shortdescription>Usefull INTELLIGENT helper to built a the ORDER BY postfix sql string.</shortdescription></doc></function><function name="useDb" undoc="true" access="private"><doc><parameter name="$db" undoc="true"/><return type="void"/></doc></function><function name="useDbName" undoc="true" access="private"><doc><parameter name="$name" type="string" undoc="true"/><return type="void"/></doc></function><function name="dbDeleteByID" undoc="true" access="private"><doc><parameter name="$id" undoc="true"/><return type="void"/></doc></function><function name="rlArrayToHashArray" undoc="true" access="private"><doc><parameter name="&amp;$rlArray" undoc="true"/><parameter name="$hashKey" type="string" undoc="true"/><return type="void"/></doc></function><variable name="$_bsDb" access="private" type="object [unknown]"><doc><description>here (maybe even from another server) we prefer to open a new connection.</description><shortdescription>db object. is not necessarily the global one! if we use another database</shortdescription></doc></variable><variable name="$_dbName" access="private" type="object [unknown]"><doc><description/><shortdescription>the database name that is in use.</shortdescription></doc></variable><variable name="$_dbTableName" access="private" type="object [unknown]"><doc><description/><shortdescription>the database table name that is in use.</shortdescription></doc></variable><variable name="$_recordData" access="private" type="array"><doc><see type="function">_hasData()</see><description/><shortdescription>the record data to work with.</shortdescription></doc></variable><constant name="BS_DBWRAPPER_VERSION" undoc="true" access="private" case="default: case sensitive">4.0.$x$<doc></doc></constant><inherited src="Bs_Object" type="functions"><element>isex</element><element>isexception</element><element>tostring</element><element>tohtml</element><element>persist</element><element>unpersist</element><element>bs_object</element><element>bbsetoutput</element><element>bbawake</element><element>bbisawake</element><element>bbxmsg</element><element>bbxfunctionstart</element><element>bbxfunctionend</element><element>bbxecho</element><element>bbxvar</element><element>bbxvardump</element><element>bbforcetrace</element><element>bbbufferstart</element><element>bbbufferget</element><element>bbbufferendflush</element><element>bbbufferendclean</element></inherited><inherited src="Bs_Object" type="consts"><element>bs_object_version</element></inherited><path><parent>Bs_Object</parent></path><baseclass>Bs_Object</baseclass></class></phpdoc>