dtlrp119999 2015-04-27 16:01
浏览 49

使用PHP更新Google电子表格中的行数

im using google spreadsheets as means of recording timestamp. im using farinspace googlespreadsheet php and zendgdata. i can add new rows with no problem , but i just found myself in a problem...

what happens if i want to updateRow, where column name is equal to todays day,,,in other words i want to update the timestamp today, being monday,,,and when i do, all rows with value Monday on the Day column gets timestamp...

i just need to do it on one row, and keep track of what row i am so i can consecutively update next days... i hope all that makes sense... if it doesnt please let me know so i can explain my self better.

include_once("Google_Spreadsheet.php");
$u = "dude@gmail.com";
$p = "dudepass";
$ss = new Google_Spreadsheet($u,$p);
$ss->useSpreadsheet($id_employee);
$id = date('l'); //this gives me todays day name
$row = array
    (
         "In" => date("H:i")
    ); // using this in column In, i will post date


   if ($ss->updateRow($row,"day=".$id))
    {
        echo "Updated";
    }else{
        echo "Some Error";
    }

that above is the basic function of the link above of farinspace sheet, the updateRow, loops through all rows that have the "monday" name and timestamps all of them. i need to know how can i prevent that...saying for example, today being monday update only "In" and "Out" columns of row monday,,, not all rows having monday in it

    function updateRow($row,$search)
{
    if ($this->client instanceof Zend_Gdata_Spreadsheets AND $search)
    {
        $feed = $this->findRows($search);

        if ($feed->entries)
        {
            foreach($feed->entries as $entry) 
            {
                if ($entry instanceof Zend_Gdata_Spreadsheets_ListEntry)
                {
                    $update_row = array();

                    $customRow = $entry->getCustom();
                    foreach ($customRow as $customCol) 
                    {
                        $update_row[$customCol->getColumnName()] = $customCol->getText();
                    }

                    // overwrite with new values
                    foreach ($row as $k => $v) 
                    {
                        $update_row[$this->cleanKey($k)] = $v;
                    }

                    // update row data, then save
                    $entry = $this->client->updateRow($entry,$update_row);
                    if ( ! ($entry instanceof Zend_Gdata_Spreadsheets_ListEntry)) return FALSE;
                }
            }

            return TRUE;
        }
    }

that is the updateRow function

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题